[Chicago-talk] Arrays of array references

Randal L. Schwartz merlyn at stonehenge.com
Fri Nov 4 20:06:54 PDT 2011


>>>>> "Clyde" == Clyde Forrester <clydeforrester at gmail.com> writes:

Clyde> @mess = ( [ "foo" , "bar" ],
Clyde>           [ "baz" , "quux" ], );
Clyde> push @mess, [ "fred" , "wilma" ];

Clyde> Then I can get the size of the array, or one element like this:

Clyde> print @mess."\n"; # 3, the size of the mess array
Clyde> print $mess[2][1]."\n"; # wilma, the second element of the array pointed
Clyde>                         # to by the third element of the mess array

Clyde> But I would like to know how to print the contents of the array to which the
Clyde> third element points. Something which would print:

Clyde> fred wilma

Third element: $mess[2]
Third element dereferenced as an array @{$mess[2]}
printed: print "@{$mess[2]}\n";

perldoc perlreftut and friends.

Alpaca book if you want a lot more detail and exercises.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion


More information about the Chicago-talk mailing list