in reply to Re^3: replace text using hash
in thread replace text using hash

So, what can I do in that case?

Replies are listed 'Best First'.
Re^5: replace text using hash
by kennethk (Abbot) on Sep 09, 2014 at 15:15 UTC
    while (<DIC>) { my ( $key, $tgt ) = split(/\t/, $_); push @{ $dictionary{$key} }, $tgt; }
    Puts an array reference in each hash value, not the scalar value as you intend. You should only be doing this if you require a one-to-many mapping, which makes no sense in this context. What you actually want is to just assign the value:
    while (<DIC>) { my ( $key, $tgt ) = split(/\t/, $_); $dictionary{$key} = $tgt; }

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Re^5: replace text using hash
by LanX (Saint) on Sep 09, 2014 at 15:34 UTC
    This is not a code writing service for homework tasks.

    Cheers Rolf

    (addicted to the Perl Programming Language and ☆☆☆☆ :)