Thanks for that Jenda Krynicky wrote:
> Then how come > > $x = 'Hello'; > sub foo { > $_[0] = 'Hi'; > } > foo($x); > print $x,"\n"; > > prints > Hi > ? > > The parameters are passed by reference, though in little strange way. > If for example you include an array (and I mean array, not array > reference!) then the function gets the elements of the array ... but > still by reference: > > $x = 0; > @a = (1,2); > sub foo { > for (@_) { > $_ += 10; > } > } > foo( $x, @a); > print "\$x = $x\n"; > print "\@a = @a\n"; > > It's when you do the usual > my $var = shift; > or > my ( $a, $b, $c) = @_; > that Perl makes copies of the parameters. If you do not shift() and > access @_ directly you CAN modify the parameters. > > Jenda > =========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ========== > There is a reason for living. There must be. I've seen it somewhere. > It's just that in the mess on my table ... and in my brain > I can't find it. > --- me > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]