Speaking of things being written in a "somewhat weird fashion", I find this bothersome (even as corrected by almut):
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; } }
I think this would make more sense:
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; } }
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.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.