The simplest is to pass as reference:
                my_subroutine( \%input_parm )
        Now in the subroutine:
        my ( $input_parm ) = @_;
        To work with you would can use this notation:
                if (input_parm->{CUSTID} == 23489) {
                   # when equal to do somethin
                 }else {
                   # when not equal do something
                 }

        When used like this, you can update the hash. Can be used for arrays in the 
same way.

Wags ;)
-----Original Message-----
From: John Crockett [mailto:[EMAIL PROTECTED]]
Sent: Saturday, March 02, 2002 08:17
To: [EMAIL PROTECTED]
Subject: How do I pass a hash to a sub, and get to it in the sub?


I'm sure this is such a simple thing, most of you-all are laughing at me
right now.

main_program
{
    blah;
    blah;

    %input_parm = ();
    $input_parm{PRICE} = "42.00";
    $input_parm{PRODUCT_ID} = "1306";
    $input_parm{INVENTORY_LOC} = "107";
    $input_parm{CUSTID} = "23489";

    my_subroutine(%input_parm);

    more irrelevant code;
    .
    .
    .
}


sub my_subroutine(%)
{
    This is where I have trouble. I can't figure out the notation for
reading the hash!
}


Thanks for your help.

John Crockett
[EMAIL PROTECTED]

(Take out NoSpam to e-mail me)



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to