CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
about arrays of arrays

 



kevindai
Novice

Apr 11, 2009, 2:27 PM

Post #1 of 2 (458 views)
about arrays of arrays Can't Post

I am trying to make a symbol table using arrays of arrays.

Let's say; symboltable[j]

I want to get and print all the element of: @symboltable[3];
eg. @symboltable[3][1]
@symboltable[3][2]
@symboltable[3][3].......but don't want to touch the element of the first dimension i.e element of "a" dimension.


(This post was edited by kevindai on Apr 11, 2009, 2:33 PM)


KevinR
Veteran


Apr 11, 2009, 4:18 PM

Post #2 of 2 (447 views)
Re: [kevindai] about arrays of arrays [In reply to] Can't Post

It depends a bit on how you initially create the array of arrays, but assuming you are not using a reference to an array of arrays you could do it like this:


Code
use strict; 
use warnings;
my @array = ([1 .. 4],[5 .. 8],[6 .. 9]);
foreach my $t (@{$array[2]}){
print "$t\n";
}


Reading material:

http://perldoc.perl.org/perllol.html
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives