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

Re: Detecting Subroutine Input Type

by Chady (Priest)
on May 03, 2004 at 06:07 UTC ( [id://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/

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://349927]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-03-29 02:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found