in reply to Re^2: next statement logic
in thread next statement logic

If that is an example of what you want to achieve, here is the logic to follow:

1) Everything is printed to OUTPUT1, including anything that matches in either %hash1 or %hash2.

2) Anything found in %hash2 should also be printed to OUTPUT2.

If I have that correct, then my example should be changed to the following:

while ($line = <MAIN_FILE1>){ chomp $line; print OUTPUT1 "$filename\n"; if (exists $hash2{$entry}) { print OUTPUT2 "$filename\n"; } } close(MAIN_FILE1)
Note that no next statement is needed, regardless of the order of print/if.

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re^4: next statement logic
by Not_a_Number (Prior) on Feb 20, 2006 at 20:13 UTC

    Dear OP,

    As you see, we are still confused, even after your update. QM has interpreted your requirements as above. My solution, below, interprets them as follows:

    1) Anything found in %hash1 should be printed to OUTPUT1.

    2) Anything found in %hash2 should be printed to OUTPUT2.

    3) Anything found in both hashes should be printed to both OUTPUT1 and OUTPUT2.

    4) Anything found in neither hash should be printed to OUTPUT1.

    Which of these interpretations is yours? (If we've both still misunderstood, please try to be very clear in your answer :).