Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Use of wantarray Considered Harmful

by kyle (Abbot)
on Dec 12, 2008 at 16:09 UTC ( [id://729965]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub get_x {
        my @x = qw( stuff );
        return wantarray ? @x : \@x;
    }
    
  2. or download this
        return wantarray ? @x : \@x;
    
  3. or download this
        return wantarray ? @x : $x[0];
    
  4. or download this
    my $dewdrop_description = get_droplet();
    $dewdrop_description->{substance}       = 'water';
    $dewdrop_description->{molecular_array} = get_moles( 'water' );
    $dewdrop_description->{temperature}     = 37;
    
  5. or download this
    my $dewdrop_description = {
        %{ get_droplet() },
    ...
        molecular_array => get_moles( 'water' ),
        temperature     => 37,
    };
    
  6. or download this
        return wantarray ? @moles : \@moles;
    
  7. or download this
    my ($scalar) = why();
    
  8. or download this
    sub get_or_set {
        my $self = shift;
    ...
    
        return $self->{stuff};
    }
    
  9. or download this
    my @x = ();        # but I thought it was qw( foo ) !
    get_or_set( @x );  # set value
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-30 02:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found