|XP is just a number|
Re^2: Reading two text files parallelly...by Marshall (Prior)
|on Nov 09, 2010 at 17:16 UTC||Need Help??|
while (my $test1 = <$fh1>, my $test2 = <$fh2>) This is "comma operator". The "true" or "false" of the "while" only depends upon the state of $test2. The comma operator is a way to combine two what normally would be completely separate statements "together". This should be used only with extreme caution.
A common use for this is in user prompting loops. Putting the prompt together with the ending condition solves the problem of "how to get the loop started" and at the same time puts the condition that is going to stop the loop right up there where it belongs - right in the statement that runs the loop - not buried somewhere in the "guts".
Here is an example. We are asking about part numbers. The user prompt is clear. What stops the loop is clear (q,Q,QuIT, etc) and it is right there where it is supposed to be, in the controlling loop statement. In the "guts" of the loop there will be many error messages like "hey, dummy a part number needs 10 digits" or whatever, followed by a "next;" statement - that restarts the loop and re-prompts the user.
Some would argue that it is better to move the ending condition into the loop and make it the first statement. Well ok thats one way. In that case we have:
last if $line !~/^\s*q(uit)?\s*$/i;
I would argue against that as "do forever" loops should be reserved for servers, GUI event loops and such.
In any event, the OP doesn't appear to be in need of such things.