tokuhirom's Blog

re.pm clobbers $_(5.14.0 〜 5.16.0)

This code makes failure in that version of perl5.

% perl -e "require re; re->import('/aa') for qw(mattn);"
Modification of a read-only value attempted at /home/tokuhirom/perl5/perlbrew/perls/perl-5.16.0/lib/5.16.0/x86_64-linux-thread-multi/re.pm line 145.

This issue was fixed in 5.16.1 release.

The commit is here:
https://github.com/mirrors/perl/commit/48895a0d

Workaround for older perl is:

BEGIN { local $_; require re; re->import("/aa"); }
# instead of
use re "/aa";

re.pm is used by charnames.pm, if you are using charnames.pm in your code, take carefully.

Encode::JP::Mobile using charnames.pm. Then it have a $_ issue. I patched workaround in Encode::JP::Mobile 0.29.
https://metacpan.org/release/MIYAGAWA/Encode-JP-Mobile-0.29