Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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 );

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://668282]
help
Chatterbox?
[choroba]: Monopoli looks nice, but a bit far from here.

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2018-01-23 12:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (245 votes). Check out past polls.

    Notices?