Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Passing multiple hashes?

by VSarkiss (Monsignor)
on Dec 11, 2001 at 05:37 UTC ( [id://130835]=note: print w/replies, xml ) Need Help??


in reply to Passing multiple hashes?

Perl passes everything to your subroutine in the @_ array, so it can't tell where one hash ends and the other begins. Everything will end up in your first hash, as you've found.

TIMTOWTDI, but probably the easiest is to pass references instead:

sub register { my ($eref, $fref) = @_; my %error = %$eref; my %FORM = %$fref; # ... } # # Call it like so: # register(\%error, \%FORM);

HTH

Replies are listed 'Best First'.
Re: Re: Passing multiple hashes?
by Monolith-0 (Beadle) on Dec 12, 2001 at 08:07 UTC

    Thanks, that's just what I needed. Unfortunatly, when I try it exactly that way, I occationally get the error:

    Can't use an undefined value as a HASH reference at A_user.pm line 54.
    Where line 54 is:
    my %error = %$eref;
    I managed to avoid this by just using the refs directly:
    $$error_ref{'any'};

    - Monolith

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://130835]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-20 01:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found