Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Return a list or an iterator

by nferraz (Monk)
on Apr 17, 2006 at 09:34 UTC ( [id://543785]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        sub foo {
            # ...
            return wantarray? @foo : \@foo;
        }
    
  2. or download this
        sub foo {
            # ...
            return wantarray? @foo : sub { shift @foo if @foo };
        }
    
  3. or download this
        my @array = foo( $x );
    
        foreach ( @array ) {
            # do something
        }
    
  4. or download this
        my $iter = foo( $x );
    
        while ( my $row = $iter->() ) {
            # do something
        }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://543785]
Approved by planetscape
Front-paged by rinceWind
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-19 11:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found