Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
for my $directory (@directories) { # read all subdirs $hierarchy{$directory} = (); opendir DIR, $directory; for my $filename (readdir DIR) { # remove filename extension ($filename) = split('.', $filename); print $filename; push($hierarchy{$directory}, $filename); } closedir DIR; }
Produces the following error:
Type of arg 1 to push must be array (not hash element) at admin.pl line 230, near "$filename)"
How do I force each hash element to contain an array?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Forcing Array Context
by broquaint (Abbot) on Jun 25, 2003 at 09:29 UTC | |
by Anonymous Monk on Jun 25, 2003 at 09:36 UTC | |
by broquaint (Abbot) on Jun 25, 2003 at 09:51 UTC | |
|
Re: Forcing Array Context
by ViceRaid (Chaplain) on Jun 25, 2003 at 09:32 UTC | |
by Anonymous Monk on Jun 25, 2003 at 09:46 UTC | |
by ViceRaid (Chaplain) on Jun 25, 2003 at 10:05 UTC | |
by Anonymous Monk on Jun 25, 2003 at 09:57 UTC | |
by ViceRaid (Chaplain) on Jun 25, 2003 at 11:16 UTC | |
by Anonymous Monk on Jun 25, 2003 at 15:32 UTC |