in reply to Re: Values passed into a sub routine
in thread Values passed into a sub routine

I like this way as you stated, but:
build_url( $account,[$fname], [$lname]); sub build_url { my $lname = pop; my $fname = pop; print "$lname and $fname\n"; my ($account ,$transaction, $location) = @_; ... }

If a run this I am getting this:
Lname=ARRAY(0x8967f28) and Fname=ARRAY(0x8967748)
Any suggestion? Thanks!

Replies are listed 'Best First'.
Re^3: Values passed into a sub routine
by ikegami (Patriarch) on Apr 19, 2011 at 17:25 UTC

    To put it differently, I understood that you want to support the following three calling conventions and only those three calling conventions:

    build_url($account, $fname, $lname); build_url($account, $transaction, $fname, $lname); build_url($account, $transaction, $location, $fname, $lname);

    If so, all three alternatives I provided should work.

Re^3: Values passed into a sub routine
by Anonymous Monk on Apr 19, 2011 at 18:11 UTC
    What about this:
    build_url( account => $account, fname => $fname, lname => $lname], ); sub build_url { my (%args) = @_; my $account = $args{account} || ''; my $fname = $args{fname} || ''; my $lname = $args{lname} || ''; my $other = $args{other} ||''; ... }

    There, it should prevent it to be out of order right?