[oclug] Perl Q. (accessing anonymous hash of array)
Michael P. Soulier
msoulier at digitaltorque.ca
Tue Jun 24 22:35:14 EDT 2003
On 24/06/03 Jon Earle did speaketh:
> my @users = $query->param('users');
> return unless @users;
>
> unless ($query->param('conf')) {
> &confirm_delete('delete', {'users' => [ @users ]});
Note: & prefix no longer required for this calling syntax.
> exit;
> }
>
> and confirm_delete has relevant lines, thus:
>
> my ($action, $hashref) = @_;
>
> foreach (@$hashref{'users'}) {
> print "<input type='hidden' name='users' value=\"$_->[0]\">\n";
> }
$hashref is just that. It's a reference to a hash. I think that you
want is...
foreach (@{ $hashref->{users} })
Hmm, lets try that.
main::(-e:1): 0
DB<1> $hashref = {users => [ 'one', 'two' ] }
DB<2> x $hashref
0 HASH(0x82116f4)
'users' => ARRAY(0x804c1ac)
0 'one'
1 'two'
DB<3> x @{ $hashref->{users} }
0 'one'
1 'two'
Yup, that should work.
Mike
--
Michael P. Soulier <msoulier at digitaltorque.ca>, GnuPG pub key: 5BC8BE08
"...the word HACK is used as a verb to indicate a massive amount
of nerd-like effort." -Harley Hahn, A Student's Guide to Unix
IM: msoulier at jabber.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://tux.oclug.on.ca/pipermail/oclug/attachments/20030624/b5741acd/attachment.bin
More information about the OCLUG
mailing list