[JaxPM] syslog analyzing
j proctor
jproctor at oit.umass.edu
Sat Apr 8 08:03:56 CDT 2000
On the jacksonville-pm-list; Jax.PM'er j proctor <jproctor at oit.umass.edu> wrote -
> foreach $hash (%postfix, %mars, %jupiter, %szebra, %wwwsaigon,
> %sol, %mercury, %zeus ) {
> while(($key, $val)=(each $hash )){
>
[...]
>
> Type of arg 1 to each must be hash (not scalar deref) at test-sort.pl line
> 140, near "$hash )"
> test-sort.pl had compilation errors.
I think, because you're trying to assign a list of hashes in turn to a
scalar, that foreach is actually giving you a reference to each hash
instead. Since I'm pretty sure foreach %hash... won't work, what you need
to do is tell the each that you're giving it a hash ref instead of an
actual hash. Well, more precisely, to dereference it back to a hash.
Try this:
while(($key, $val)=(each %{$hash} )){
Caution: it's Saturday morning, and I neither drink coffee on Saturdays
nor usually attempt to code before noon or so. :)
j
Jax.PM Moderator's Note:
This message was posted to the Jacksonville Perl Monger's Group listserv.
The group manager can be reached at -- owner-jacksonville-pm-list at pm.org
to whom send all praises, complaints, or comments...
More information about the Jacksonville-pm
mailing list