Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: reading the wrong input file out of 2 opened file

by Anonymous Monk
on Jan 24, 2022 at 16:21 UTC ( [id://11140808]=note: print w/replies, xml ) Need Help??


in reply to Re: reading the wrong input file out of 2 opened file
in thread reading the wrong input file out of 2 opened file

The reads a line from F1 and puts it into $_

wrong

  • Comment on Re^2: reading the wrong input file out of 2 opened file

Replies are listed 'Best First'.
Re^3: reading the wrong input file out of 2 opened file
by Marshall (Canon) on Jan 24, 2022 at 16:58 UTC
    You are correct. This is an artifact of having the logical statement in the conditional. while (<FH>){} does assign the line to $_. However, while (<FH> and some condition){} doesn't assign the read line to $_ only the "truthiness" of whether a line was actually read or not is used (the line itself is thrown away). Ok, we have found yet another reason why this odd looking while statement won't work. while (defined (my $line =<FH>) and some condition){} is perhaps better. It is possible to assign to $_ (left hand side), but I seldom do that. This whole idea of an "and" or "&&" statement in the while condition looks dubious to me.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11140808]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2024-04-25 11:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found