SPUG: each function won't recognize hash deref

starfire at zipcon.net starfire at zipcon.net
Thu Jun 1 12:36:25 CDT 2000


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 "("

If this were C, I would throw in a typecast.  Do I need to bless my hashref
somehow?

Richard.Anderson
Richard.Anderson at raycosoft.com
www.unixscripts.com

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     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