Chas. Owens wrote:
On Sat, Apr 19, 2008 at 6:08 PM, Richard Lee <[EMAIL PROTECTED]> wrote:
snip
 sub process_it {
    my($variable, $hash_table) = shift;

 }

 when I change to separate shift

 my $variable = shift;
 my $hash_table = shift;

 it worked...   are they different?
snip

Yes, shift returns one item from the array it is working on, so the
first is like saying

my ($variable, $hash_table) = 5;

$variable will be 5 and $hash_table will be undefined.  To get what
you want you must either say

my ($variable, $hash_table) = (shift, shift);

It would be better to do:

my ($variable, $hash_table) = splice @_, 0, 2;

Then you are guaranteed that $_[0] goes to $variable and $_[1] goes to $hash_table.



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to