gri6507 has asked for the wisdom of the Perl Monks concerning the following question:
I know this should be simple, but I am tired and am not seeing the problem. Here's my code:
use strict; use warnings; use Data::Dumper; my @trainset = (); while (my $pattern = <DATA>) { chomp $pattern; next if ($pattern =~ /#/); my ($inputs,$outputs) = split(/=>/,$pattern); my @inputs = split(/,/,$inputs); my @outputs = split(/,/,$outputs); $trainset[scalar(@trainset)] = \@inputs; $trainset[scalar(@trainset)] = \@outputs; } print Dumper(\@trainset); my @set = ( [0,0] => [0], [0,1] => [1], ); print Dumper(\@set); __DATA__ 0,0=>0 0,1=>1 #not used
The two arrays should be the same, but the output of Data::Dumper on the two arrays is different (when read in from a handle, the values in the arrays are scalars instead of numbers) and I think it's causing me problems further on. What am I doing wrong?
Thanks a bundle.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Array definition error
by sasikumar (Monk) on Apr 15, 2005 at 15:32 UTC | |
by RazorbladeBidet (Friar) on Apr 15, 2005 at 15:47 UTC | |
|
Re: Array definition error
by RazorbladeBidet (Friar) on Apr 15, 2005 at 15:21 UTC | |
by gri6507 (Deacon) on Apr 15, 2005 at 15:25 UTC | |
by JediWizard (Deacon) on Apr 15, 2005 at 15:49 UTC | |
|
Re: Array definition error
by gri6507 (Deacon) on Apr 15, 2005 at 15:21 UTC | |
by Roy Johnson (Monsignor) on Apr 15, 2005 at 15:32 UTC | |
|
Re: Array definition error
by sh1tn (Priest) on Apr 15, 2005 at 15:22 UTC | |
by gri6507 (Deacon) on Apr 15, 2005 at 15:29 UTC |