Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Detecting Subroutine Input Type

by Chady (Priest)
on May 03, 2004 at 06:07 UTC ( #349927=note: print w/ replies, xml ) Need Help??


in reply to Detecting Subroutine Input Type

You need ref, like so:

sub thinger { my @array; if (ref($_[0]) eq 'ARRAY') { @array = @$_[0]; } else { @array = @_; } ... }

He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

Chady | http://chady.net/


Comment on Re: Detecting Subroutine Input Type
Download Code
Re: Re: Detecting Subroutine Input Type
by Anonymous Monk on May 03, 2004 at 08:21 UTC
    sub thinger { my @array = ( ref($_[0]) eq 'ARRAY' ? @{$_[0]} : @_ ); }
Re: Re: Detecting Subroutine Input Type
by doran (Deacon) on May 03, 2004 at 16:48 UTC
    Well duh! Thanks Chady (and Anon), that's what I was thinking of. Much better than what I was doing.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (18)
As of 2014-08-27 14:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (239 votes), past polls