SPUG: each function won't recognize hash deref
Joel
largest at largest.org
Thu Jun 1 12:54:07 CDT 2000
starfire at zipcon.net wrote:
> The retrieve subroutine of Storable.pm returns a hash ref. But when I
> deref the return value and pass it to the each function, perl doesn't
> recognize it as a hash:
>
> $data = retrieve("$sambadir/hitcount.dat");
> while (($key, $value) = each($$data)) {
> ...
>
> Type of arg 1 to each must be hash (not scalar deref) at hitsbyid.cgi
> line 41, near "$data)" syntax error at hitsbyid.cgi line 43, near "("
deref'ing a hash ref looks like this:
while ( ($key, $value) = each %$data ) {
Joel
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
For Subscriptions, Email to majordomo at pm.org: ACTION spug-list EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email address
More information about the spug-list
mailing list