[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] Little puzzle for Perl gurus
Hello,
Sorry, this is more of a Perl issue than Interchange,
but I'm stumped here.
The following gives me the result I expected:
##########################################
sub do_order_action {
my $page="";
my ($ordernumber,$orderline,%subref,%CGI)=@_;
my @keysar=keys %subref;
foreach my $ky (@keysar) {$page.=$ky;}
my $comment=$CGI->{"comment_$orderline"};
return $page."... subref{hello}=$subref{hello}, comment=$comment";
}
do_order_action($CGI->{order},$line,%ref2sub,%CGI);
##########################################
Output of the function is:
pending_cancelledpending_packingpending_backorderbyehello...
ref2sub{hello}=CODE(0x92837ac), comment=
After swapping the last two subroutine parameters both
in the sub and the call to it, the function outputs:
... ref2sub{hello}=, comment=
##########################################
sub do_order_action {
my $page="";
my ($ordernumber,$orderline,%CGI,%subref)=@_;
my @keysar=keys %subref;
foreach my $ky (@keysar) {$page.=$ky;}
my $comment=$CGI->{"comment_$orderline"};
return $page."... subref{hello}=$subref{hello}, comment=$comment";
}
do_order_action($CGI->{order},$line,%CGI,%ref2sub);
##########################################
Although things seem to work OK in the first version,
I think it's a bit creepy to not understand why swapping
the parameters makes a difference. What am I missing?
Regards,
Marc Brevoort