Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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 taking refuge in the Monastery: (2)
As of 2018-07-22 11:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (454 votes). Check out past polls.

    Notices?