[Chicago-talk] Arrays of array references

Clyde Forrester clydeforrester at gmail.com
Fri Nov 11 12:03:35 PST 2011


FWIW: The program worked! =:-D

It was a program to count the number of occurrences of the sequence 
"GATTACA" in each chromosome in the standard human genome. It used an 
array of pointers to state-machine objects. Pretty nifty, I think.

Clyde

Randal L. Schwartz wrote:
 >>>>>> "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.
 >



More information about the Chicago-talk mailing list