I've been fooling around with this situation entirely too long. Below is
a demonstration of the problem, but the real situation is part of some
Win32::OLE code I am maintaining, so it's relevant <g>.
The problem is this: the 1st loop pushes each sub-array (for example
"39", "3") onto @toparray. A print statement shows that it is "39", "3"
(for example).
In the 2nd loop, I want to pull each sub-array as it was pushed on, but
instead I get the first "this is line:" statement, and an error: "Can't
use string ("39") as an ARRAY ref while "strict refs" in use at
test42.pl line 39.".
I know this smells like a newbie problem, but I'm not a newbie;
nevertheless, I guess I do not know enough about array references yet.
Barry Brevik
==========================================
use strict;
use warnings;
my @bartypes =
(
[
['39', '3'],
['128', '1'],
['128A', '1A'],
['128B', '1B'],
['128C', '1C']
],
[
['yes', 'A'],
['no', 'B'],
['maybe', 'C'],
['ask later', 'D'],
['answer hazy', 'E']
]
);
my @toparray = ();
foreach my $bartype (@bartypes)
{
foreach my $record (@$bartype)
{
push @toparray, @$record;
print @$record, "\n";
}
}
print "\n\n";
foreach my $line (@toparray)
{
print "this is line: $line\n";
foreach my $cell (@{$line})
{
print " cell: $cell\n";
}
print "\n";
}
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs