Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^4: Use of uninitialized value in pattern match (m//)

by Anonymous Monk
on Mar 18, 2015 at 01:24 UTC ( [id://1120406]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Use of uninitialized value in pattern match (m//)
in thread Use of uninitialized value in pattern match (m//)

The part in parens produces an anonymous array that the "for" will iterate over, and the last element of that array the "undef" element from the last attempt to read from the file handle and encountering 'eof'. If you used a while loop instead, you wouldn't enter the block (lines 25 and 26 would not be reached) on that last attempt to read from the file.

um, none of that :) if the match fails $participant is undef , when you try to print var which is undef you get uninitialized warning

$ perl -MData::Dump -we " open $fake, q{<}, \qq{a\nb\nc\n\n}; for(<$fa +ke>){ dd($_); }" "a\n" "b\n" "c\n" "\n"

Replies are listed 'Best First'.
Re^5: Use of uninitialized value in pattern match (m//)
by graff (Chancellor) on Mar 18, 2015 at 01:36 UTC
    Thanks - that should teach me to avoid posting guesses...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-04-25 16:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found