in reply to Re: Trouble iterating through a hash
in thread Trouble iterating through a hash

I have no idea about what you think this $N stuff does?

I had a clue, er a guess, so i tested it. next if 1..$N==$.; skips the first line, kinda the hard way.

I agree with your other points, except that as written $info2 = $hash2 -> {$prog} -> {info2}; doesnt hurt either, it does that when the -> is assumed in $info2 = $hash2 -> {$prog}{info2}; anyway

Replies are listed 'Best First'.
Re^3: Trouble iterating through a hash
by Marshall (Canon) on Mar 09, 2017 at 05:49 UTC
    I agree with you "skips the first line, kinda the hard way.".

    I would advise the OP to use:

    my $discard_first_line = <FILE1>;
    before starting the while loop.
    The more cryptic albeit simple: <FILE1>; would work also. I prefer the extraneous "my" variable because it is very "cheap" and it is clear what it does. I would personally write a comment like <FILE1>; #discard first line anyway.

    I agree with your other points, except that as written $info2 = $hash2 -> {$prog} -> {info2}; doesnt hurt either, it does that when the -> is assumed in $info2 = $hash2 -> {$prog}{info2}; anyway
    My point is that there is no need at all for a 2nd dimension on the first hash, and no need for the 2nd hash at all!