wp.jochen.hayek.name/blog-en

Perl’s Encode.pm: calling encode differently on the same encoding handle does not yield the expected result

I have a scenario, where I call encode on the same encoding handle a couple of times and with different values for CHECK.

Initially I just used encode with a coderef for CHECK, because that lets me handle replacement situations best.

Then I had to enhance the code with a pre-check on the replacement character: So I run encode with FB_CROAK for CHECK w/o considering the result, just checking for an exception resp. $@.

But this 1st run of encode has a disturbing impact on the further runs of encode — they won’t run as expected with that 1st check in place.

W/o that 1st check, everything is fine.

If I replace the 1st check with another coderef for CHECK, everything is fine again.

That rather worries me.

Exit mobile version