Jeff Pan wrote: > Passing reference as parameter to subroutine is as easy as the normal > way.And,if u pass some types of parameter such as hash,array,or handle > to subroutine,using reference instead is more safer. > for example,such below code is right:
It is, however it could be better. > my (%hash,@array); > &sub_test(\%hash,[EMAIL PROTECTED]); & has special meaning so it should be dropped when not needing particular special behavior. > sub sub_test{ > my ($hash_ref,$array_ref)[EMAIL PROTECTED]; ok. > my %hash=%$hash_ref; > my @[EMAIL PROTECTED]; This isn't needed actually and it only makes unnecessary overhead as keys/values are copied, so you immediately lost benefit by passing by reference. It's better to access them directly like, $hash_ref->{key} $array_ref->[0] > do something... > } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>