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

Re: elegant array assignment

by snoopy (Deacon)
on Feb 16, 2008 at 00:08 UTC ( #668282=note: print w/ replies, xml ) Need Help??

in reply to elegant array assignment

If an object has been blessed, Perls ref built in will return the class, not its type. Thus this code might not do what you expect for blessed array references.

Scalar::Util's reftype function consistantly returns the type and might be a better choice here:

use Scalar::Util qw/reftype/; my @arr = reftype( $x ) eq 'ARRAY' ? @$x : ( $x );

Comment on Re: elegant array assignment
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2015-07-07 05:26 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (87 votes), past polls