Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: size of an array ref

by moritz (Cardinal)
on Feb 24, 2012 at 12:52 UTC ( [id://955908]=note: print w/replies, xml ) Need Help??


in reply to size of an array ref

# array: $ perl -wE 'my @a = qw/a b c/; say scalar @a' 3 # array ref: $ perl -wE 'my $a = [qw/a b c/]; say scalar @$a' 3

See also: perlreftut, References Quick Reference

Replies are listed 'Best First'.
Re^2: size of an array ref
by fionbarr (Friar) on Feb 24, 2012 at 13:00 UTC
    that makes sense...I might have a reference to a reference to an array...I've tried a lot of permutations and not gotten '3'...is it possible to get the size of a ref to a ref?
      @array; @$arrayref; @$$arrayrefref; @$$$arrayrefrefref; @$$$$arrayrefrefrefref; @$$$$$arrayrefrefrefrefref; @$$$$$$arrayrefrefrefrefrefref; ... etc ...
      $a= [1..10];$b=\$a;$c=\$b; $d=\$c;$e=\$d; $e=$$e while (ref($e) eq "REF"); print scalar @$e;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-16 05:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found