Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: returning tied array

by AK108 (Friar)
on Jan 08, 2007 at 02:36 UTC ( #593467=note: print w/replies, xml ) Need Help??


in reply to Re^2: returning tied array
in thread returning tied array

If you return a list from a subroutine, then you get that list back. If it was in scalar context, then you only get the first item of the list.

You can use wantarray to see what context you were called in.

Update: s/\barray\b/list/g per chromatic's comment.

Replies are listed 'Best First'.
Re^4: returning tied array
by chromatic (Archbishop) on Jan 08, 2007 at 04:52 UTC

    You can only return scalars and lists and (nothing) from subroutines. You can't return arrays or hashes directly, only as lists or references.

      Good point. I updated my above post to correct that.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2021-06-22 02:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (100 votes). Check out past polls.

    Notices?