Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: Splitting in while loop

by AnomalousMonk (Archbishop)
on Oct 07, 2021 at 07:21 UTC ( [id://11137290]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Splitting in while loop
in thread Splitting in while loop

while (split(/[, ]+/, <DATA>)) { ... }

Only a while-loop condition expression like

while (<DATA>) { ... }
assigns implicitly to $_ (see tybalt89's example) (update: but see kcott's post for a more complete discussion of $_ assignment special-casing). An arbitrary expression like split(...) does not. Had you had warnings enabled, Perl would have at least hinted at this problem.


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2024-04-23 10:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found