gorillaman has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to pass a hash and a separate scalar to a subroutine. The hash contains the new data that will go into the database, and the scalar indicates the account to make the changes to. But at this point, the sub mixes everything together into a pile of goo. The scalar gets mixed into the hash, and the hash turns into an array.
I've tried using the docs, but I only got more confused, I think I might be missing something elementary here.
%new_stuff = ("RATING" => 4.99); &db_modify_account("jdonald", %new_stuff); sub db_modify_account { my %new_data = @_; while (($key, $value) = each %new_data) { print "The $key is: $value.<BR>"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing a hash, and a scalar to subroutine
by davido (Cardinal) on Jul 17, 2004 at 07:36 UTC | |
|
Re: Passing a hash, and a scalar to subroutine
by meredith (Friar) on Jul 17, 2004 at 05:02 UTC | |
by gorillaman (Acolyte) on Jul 17, 2004 at 05:11 UTC | |
by hbo (Monk) on Jul 17, 2004 at 05:48 UTC | |
|
Re: Passing a hash, and a scalar to subroutine
by murugu (Curate) on Jul 17, 2004 at 06:49 UTC |