Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
go ahead... be a heretic
 
PerlMonks  

Re: help needed in wantarray

by xdg (Monsignor)
on Feb 10, 2006 at 07:46 UTC ( [id://529346]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to help needed in wantarray

The "context" means the context that the function is called in -- whether the values of the function will be used in list or scalar context.

use strict; use warnings; sub what_do_you_want { print wantarray ? "list\n" : "scalar\n"; } my @list = what_do_you_want(); # prints "list" my $scalar = what_do_you_want() # prints "scalar"

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://529346]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.