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

Re: size of an array ref

by moritz (Cardinal)
on Feb 24, 2012 at 12:52 UTC ( #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' 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?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2019-03-22 14:45 GMT
Find Nodes?
    Voting Booth?
    How do you Carpe diem?

    Results (113 votes). Check out past polls.