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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

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



Apr 11, 2009, 2:27 PM

Post #1 of 2 (873 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][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)


Apr 11, 2009, 4:18 PM

Post #2 of 2 (862 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:

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

Reading material:


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

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