Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: split and uninitialized variables

by ikegami (Patriarch)
on Sep 03, 2004 at 15:31 UTC ( [id://388310]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my ($x, $y, $z) = ('', '', '');
    ($x, $y, $z) = split(',', $_);
    
  2. or download this
    $_ = 'a,b';
    my ($x, $y, $z) = ('', '', '');
    ($x, $y, $z) = split(',', $_);
    print(defined($z)?'defined':'undefined', "\n");
    # prints undefined.
    
  3. or download this
    my ($x, $y, $z) = map { defined($_)?$_:'' } (split(',', $_))[0..2];
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-24 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found