SPUG: assigning to slice of anon hash?
El JoPe Magnifico
jope-spug at jope.net
Wed Jun 27 14:12:53 CDT 2001
Quick (hopefully) perl syntax question that I ran into last night.
You can assign to a slice of a hash with the following:
@hash{ @fields } = @values;
However, I can't figure out how to do the same with a hash ref.
The following gives a runtime error, "Can't coerce array into hash",
since the @{$ref} construct is generally how you deref an array ref:
@{ $hash_ref }->{ @fields } = @values;
And the following (which wouldn't be syntactically consistent,
but I tried just in case) doesn't do the trick either:
%{ $hash_ref }->{ @fields } = @values;
I'm using perl 5.6.1. Assistance appreciated! =)
-jp
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list
mailing list