is_romaji affects $_ #15

furagu opened this Issue Sep 16, 2012 · 2 comments

2 participants


How to reproduce:

use Data::Dumper;

my @words = qw(hana flower tora);
my @valid_words = grep {is_romaji $_} @words;

say Dumper \@words, \@valid_words;

Notice the undefs in the output:

$VAR1 = [
$VAR2 = [

Changing {is_romaji $_} to {my $w = $_; local $_; is_romaji $w} makes things right, so I believe this is is_romaji affecting my $_.


Thank you for your bug report. I believe the bug is fixed in version 0.23, now uploaded to CPAN. This requires an upgrade of a dependency, Convert::Moji. Version 0.05 is required. A client like cpan or cpanm will upgrade Lingua::JA::Moji and get the dependency at the same time. The github versions are also updated to the latest ones. If you find this still does not work, please reopen this issue.

Details of bug fix

The bug is located in a subroutine called load_convertor in the Convert::Moji dependency. It used $_ to read from a file, and thus the first time any conversion was done, $_ would be overwritten. Load_convertor was only used once to load the file, so only the first element of the array was overwritten. I have changed load_convertor to use a variable $line for reading the lines.


Thank you for quick fix, the bug is gone now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment