Sounds like what you need here is a 2-dimensional array, what Perl calls an Array of Array's.
@input_array = ( \@row1, \@row2, \@row3);
I couldn't find a link for you that I could post here that is both informative and also that I was sure was "public domain".
Try google on "Perl array of arrays".
Some code:
Note that in Perl array indices start at
[0] not [1].
#!/usr/bin/perl;
use strict;
use warnings;
my @input_array = ( ["x","y"], ["L","M"], [2,45] );
foreach my $row (@input_array)
{
print "@$row\n";
}
print "\nanother way\n";
for (my $row=0; $row<@input_array; $row++)
{
for (my $column=0; $column <@{$input_array[$row]}; $column++)
{
print "$input_array[$row][$column] ";
}
print "\n";
}
print "\nyet, another way\n";
for (my $row=0; $row<3; $row++)
{
for (my $col =0; $col<2; $col++)
{
print "[$row][$col]=$input_array[$row][$col] "
}
print "\n";
}
__END__
x y
L M
2 45
another way
x y
L M
2 45
yet, another way
[0][0]=x [0][1]=y
[1][0]=L [1][1]=M
[2][0]=2 [2][1]=45
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.