No such thing as a small change | |
PerlMonks |
Re: Creating (and using) a custom encoding. (SOLUTION)by davido (Cardinal) |
on May 31, 2013 at 17:01 UTC ( [id://1036270]=note: print w/replies, xml ) | Need Help?? |
It turns out that most of the confusion was due to File::Slurp RT#84918, submitted by our friend corion. "File-Slurp: read_file() ignores binmode option for short files". If only I had suspected File::Slurp earlier, I could have saved myself (and others) some time. Here's a complete working example. Note, you must binmode the filehandle with ":encoding(rot13)", not the more terse ":rot13" (which simply won't work). Also, there's no need to explicitly call define_encoding from Encode within the calling package; the line __PACKAGE__->Define('rot13'); does that for us.
...and the output...
...now on to learn how to use the enc2xs tool. Dave
In Section
Seekers of Perl Wisdom
|
|