in reply to Re: Question on loops
in thread Question on loops

Hello tobyink

Thank you for the quick response. I figured that V1 and V2 were being over written had started to look at hashes. I understand what they are doing but not how to use them correctly

the code does have an error

Type of arg 1 to push must be array (not postincrement (++)) at test.pl line 10, near "++;"

Type of arg 1 to push must be array (not postincrement (++)) at test.pl line 10, near "++;"

must the V1 and V2 variables be changed to arrays before being added to the hash

Brian

I can assure you that my actual variable have appropriate names

Replies are listed 'Best First'.
Re^3: Question on loops
by tobyink (Canon) on Dec 12, 2011 at 17:48 UTC

    Meh. Remove the two pushes. Should just be:

    while (<LIST1>) { ($V1, $V2) = split /\t/; $all_V1{$V1}++; $all_V2{$V2}++; }

    ... the pushes were left overs from an earlier response I typed up but didn't submit, which used arrays.

    I'll correct the code in my original answer too.