I think this would make more sense:while ($linein = <FILEIN2>) { chomp $linein; @arrayin = split /:/, $linein; if (exists $arrayin[0] && $arrayin[0] eq "Default") { $englishword = trim( $arrayin[1] ); } if (exists $arrayin[0] && $arrayin[0] eq "Spanish_LatinAmerican|es +_MX") { $spanishword = trim( $arrayin[1] ); } if (exists $arrayin[0] && $arrayin[0] eq "Spanish_LatinAmerican|es +_MX") { $langhash{$spanishword} = $englishword; } }
It seemed to me that the OP code was doing too many unnecessary tests with all those "if" conditions, and they actually weren't entirely appropriate to the task: you only check for the existence of the first array element, and then do something with the second array element whether it exists or not.while (<FILEIN2>) { next unless ( /.:\s*\S/ ); # necessary/sufficient condition for w +hat follows my ( $lang, $text ) = split /:/, $_, 2; if ( $lang eq "Default" ) { $englishword = trim( $text ); # takes care of chomping } elsif ( $lang eq "Spanish_LatinAmerican|es_MX" ) { $spanishword = trim( $text ); $langhash{$spanishword} = $englishword; } }
And I would agree with the Anonymonk who thinks that "weird" is an understatement when describing a subroutine with a for loop that does a "return" on each iteration... {grin}
In reply to Re: Still having problems with spanish characters
by graff
in thread Still having problems with spanish characters
by qnguyen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |