Jeff Pang 写道:
Ben Edwards 写道:
I am passing a reference to a hash ($publisher) and a array with an
unknown number of elements (@files).  So the call is

delete_from_publishers( $publisher, @files )


mnnn,don't pass an original array to a subroutine at anytime.
Instead just pass a reference to routines.like,

delete_from_publishers($publisher,[EMAIL PROTECTED]);

then in the subroutine,

my $hash_ref = shift;
my $array_ref = shift;

This would make things more clear.



Also passing a reference to a routine is different in effect from passing an original structure.See below,

# this would change the original array's values
$ perl -Mstrict -le 'my @x=(1,2,3);
> testx([EMAIL PROTECTED]);
> print "@x";
> sub testx { my $re = shift; $re->[0]=111 }'
111 2 3

# but this wouldn't change original array's values
$  perl -Mstrict -le 'my @x=(1,2,3);
> testx(@x);
> print "@x";
> sub testx { my @x = @_;$x[0] =111 }'
1 2 3

--
http://home.arcor.de/jeffpang/

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


Reply via email to