Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: array or scalar, that's the question

by count0 (Friar)
on Jan 01, 2002 at 22:26 UTC ( #135533=note: print w/ replies, xml ) Need Help??


in reply to array or scalar, that's the question

Well, Parham and Juerd summed up the most common ways to do it. But for the sake of tmtowtdi, here is YAW (yet another way ;)

Rewrite the return portion of someonesFunc() to always return a scalar, either a string/number or an array refrence.

my $tmp = someonesFunc(); if ($ref $tmp eq 'ARRAY') { # use @$tmp as an array } else { # use $tmp as a scalar }


Comment on Re: array or scalar, that's the question
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2014-09-23 18:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (238 votes), past polls