Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Can't understand function returning undefs

by ikegami (Patriarch)
on Sep 24, 2010 at 21:55 UTC ( [id://861901]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @a = qw( a b c d );
    my $i = sub { @a ? splice(@a, 0, 2) : () };
    while (my ($x,$y) = $i->()) {
       print("$x:$y\n");
    }
    
  2. or download this
    my @a = qw( a b c d );
    my $i = sub { @a ? splice(@a, 0, 2) : (undef,undef) };
    while (my ($x,$y) = $i->()) {
       print("$x:$y\n");
    }
    

Log In?
Username:
Password:

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

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

    No recent polls found