L
L. D. James
I would like to thank everyone in advance for taking the time to look
at my code below. I believe the term for the variable type I'm
trying to manipulate is called matrix. It's rather new to me, and
I'm appreciative of any input on the proper nomenclature.
I know that you can evaluate the number of elements in a normal "one
dimensional" @array by assigning it to a $string value. I'm trying
to figure out how to get the number of elements from my "multi
dimensional" array, and having problems in the process.
I believe the code below might shed light on where my confusion exists,
as it produces errors which might be obvious to someone a little more
experience.
Where I attempt to output the number of elements per day I get
"ARRAY(0x903a2a0)" instead of a number. Where I try to itemize the
list ("They are:") the output is blank.
Thanks in advance for any comments on this matter.
Code begin:
---------------------------------------------------------
#!/usr/local/bin/perl
use warnings;
use strict;
use DBI;
use CGI qwstandard);
my @week;
# The week is categorized into days and items per day
$week[0][0] = "Process Agenda 1";
$week[0][1] = "Process Agenda 2";
$week[0][2] = "Process Agenda 3";
$week[1][0] = "Process Agenda 1";
$week[1][1] = "Process Agenda 2";
$week[2][0] = "Process Agenda 1";
my $numdays = @week;
print "So far there are a total of $numdays days scheduled.\n";
# Out put a list of each agenda item per day.
my $daycount = 0;
foreach my$thisday (@week)
{
# Number of elements in the @week[$daycount] row or matrix
my $itemsperday = $week[$daycount];
print "On day $daycount we have $itemsperday to do. They are:\n";
my $count = 0;
while ( $count < $daycount )
{
print "$week[$daycount][$count]\n";
$count++;
}
$daycount++;
}
at my code below. I believe the term for the variable type I'm
trying to manipulate is called matrix. It's rather new to me, and
I'm appreciative of any input on the proper nomenclature.
I know that you can evaluate the number of elements in a normal "one
dimensional" @array by assigning it to a $string value. I'm trying
to figure out how to get the number of elements from my "multi
dimensional" array, and having problems in the process.
I believe the code below might shed light on where my confusion exists,
as it produces errors which might be obvious to someone a little more
experience.
Where I attempt to output the number of elements per day I get
"ARRAY(0x903a2a0)" instead of a number. Where I try to itemize the
list ("They are:") the output is blank.
Thanks in advance for any comments on this matter.
Code begin:
---------------------------------------------------------
#!/usr/local/bin/perl
use warnings;
use strict;
use DBI;
use CGI qwstandard);
my @week;
# The week is categorized into days and items per day
$week[0][0] = "Process Agenda 1";
$week[0][1] = "Process Agenda 2";
$week[0][2] = "Process Agenda 3";
$week[1][0] = "Process Agenda 1";
$week[1][1] = "Process Agenda 2";
$week[2][0] = "Process Agenda 1";
my $numdays = @week;
print "So far there are a total of $numdays days scheduled.\n";
# Out put a list of each agenda item per day.
my $daycount = 0;
foreach my$thisday (@week)
{
# Number of elements in the @week[$daycount] row or matrix
my $itemsperday = $week[$daycount];
print "On day $daycount we have $itemsperday to do. They are:\n";
my $count = 0;
while ( $count < $daycount )
{
print "$week[$daycount][$count]\n";
$count++;
}
$daycount++;
}