Because you admitted unabashedly you're new to Perl, and because you pleaded very graciously for our help, I've taken the liberty of refactoring your script a tiny bit. I've incorporated idioms of Modern Perl and a few Perl best practices gleaned from Perl Best Practices.
#!perl # # hiragana2romaji.pl - Convert hiragana text to romaji text use strict; use warnings; use autodie; use Lingua::JA::Moji qw( kana2romaji ); @ARGV == 2 or die "Usage: perl $0 <hiragana file> <romaji file>\n"; my $hiragana_file = shift @ARGV; my $romaji_file = shift @ARGV; open my $hiragana_fh, '<:encoding(UTF-8)', $hiragana_file; open my $romaji_fh, '>:encoding(UTF-8)', $romaji_file; while (my $hiragana_text = <$hiragana_fh>) { chomp $hiragana_text; my $romaji_text = kana2romaji($hiragana_text); print {$romaji_fh} "$romaji_text\n"; } close $hiragana_fh; close $romaji_fh; exit 0;
In reply to Re: UTF8 issues
by Jim
in thread UTF8 issues
by kemuri
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |