js1 has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I get the following error when running my program:
Bad index while coercing array into hash at ...
The code causing this problem is on the print line below due to the $file->{$t} variable. If I change this to $file{$t} the error goes away, but there's no value printed. However according to the Dumper below, there should be a value there. Could anyone tell me what I do to fix this please?
Thanks,
Ed.
foreach $file (@files) { print Dumper $file; foreach $t(keys %$file){ print "\nt= $t v=" . $file->{$t}; } ..
$VAR1 = [ { 'longname' => 'drwxr-xr-x 2 1ae2ets fq 4096 +Sep 14 2007 .', 'a' => bless( { 'uid' => 2004734, 'flags' => 15, 'mtime' => 1189777443, 'atime' => 1211362016, 'perm' => 16877, 'gid' => 2004409, 'size' => 4096 }, 'Net::SFTP::Foreign::Attributes' ), 'filename' => '.' }, { 'longname' => 'drwxr-xr-x 3 1ae2ets fq 4096 +Sep 14 2007 ..', 'a' => bless( { 'uid' => 2004734, 'flags' => 15, 'mtime' => 1189777162, 'atime' => 1211317201, 'perm' => 16877, 'gid' => 2004409, 'size' => 4096 }, 'Net::SFTP::Foreign::Attributes' ), 'filename' => '..' }, { 'longname' => '-r-------- 1 root root 0 +Jan 8 2007 .mirror', 'a' => bless( { 'uid' => 0, 'flags' => 15, 'mtime' => 1168287005, 'atime' => 1189777418, 'perm' => 33024, 'gid' => 0, 'size' => 0 }, 'Net::SFTP::Foreign::Attributes' ), 'filename' => '.mirror' } ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: bad index while coercing array into hash
by BrowserUk (Patriarch) on May 21, 2008 at 10:26 UTC | |
|
Re: bad index while coercing array into hash
by Erez (Priest) on May 21, 2008 at 10:35 UTC |