Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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'...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
Node Status?
node history
Node Type: note [id://955908]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2019-10-17 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?