Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: split and uninitialized variables

by ikegami (Pope)
on Sep 03, 2004 at 15:31 UTC ( #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
Node Status?
node history
Node Type: note [id://388310]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2017-11-25 09:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (355 votes). Check out past polls.

    Notices?