Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: returning tied array

by WiseGuru (Initiate)
on Jan 08, 2007 at 00:11 UTC ( #593451=note: print w/replies, xml ) Need Help??


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

Hi all, (please ignore the "intermidate" thing) as far as i know, returning anything from a sub, object etc, usualy returns an array, sorry dont have time to check the script, but try,
@MyArray = &YourFunction(pass variables here); ## or $MyString = &YourFunction(pass variables here); ##might work! -------------- sub YourFunction{ @array =@_; (do something) return $YourString; ##wich ya get a string return @YourArray; ##wich ya get an array, i think the array objects seperated by spaces! (and furthermore you can change the space to something else through a special command to the perl interperter! :P ) } ---------------
calling objects is done a different way! :P if your going to pass hashes there is another way to do it, but ya gonna have to ask! :P

c ya, have fun! www.arobcorp.com

Replies are listed 'Best First'.
Re^3: returning tied array
by AK108 (Friar) on Jan 08, 2007 at 02:36 UTC
    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.

      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://593451]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2021-06-22 00:45 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?