in reply to Re^3: preserving hash value outside the loop -- silly oneliner
in thread preserving hash value outside the loop

Thank you everyone but the above codes not giving correct output. It is giving the count correct but $key is printing the same value everytime.
  • Comment on Re^4: preserving hash value outside the loop -- silly oneliner

Replies are listed 'Best First'.
Re^5: preserving hash value outside the loop -- silly oneliner
by Discipulus (Canon) on May 17, 2016 at 07:07 UTC
    which code is giving you always the same key? it seems not probable to me. In case post your code , your data and your output.

    Here mines:

    #cat gen1.txt @gi AGAT + AAAA 1:1.txt @gi CATT + AAAAA 3:1.txt #cat gen2.txt @gi AGAT + AAAA 1:2.txt @gi TACA + AAAA 2:2.txt perl -lane "BEGIN{$/=''}map{$h{$_}{s}.=' '.$F[4];$h{$_}{c}+=$1 if $F[ +4]=~/(\d+):/}join qq(\n),@F[0..3]; END{print map{qq($_ $h{$_}{c} $h{$_}{s}\n\n)} keys %h}" + gen1.txt gen2.txt @gi AGAT + AAAA 2 1:1.txt 1:2.txt @gi CATT + AAAAA 3 3:1.txt @gi TACA + AAAA 2 2:2.txt

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.