Hi,
<[EMAIL PROTECTED]> wrote:
> When using read/sysread you pass variables like
> $fo->sysread($buf, $buflen), and the data is returned in buf.
> This is magic to me, normally you ought to call sysread like $fo-
> >sysread(\$buf,$buflen), passing a reference/pointer to the buffer.
>
> Apparantly here's some trick, although the variable content
> is put on the perl-stack, sysread can decode the reference to
> the variable.
What actually happens is that arguments are always
passed by reference, since @_ seems to be a list of
aliases to the arguments.
That means that you can shaft yourself royally by
using map or foreach on @_ in a subroutine without
copying the arguments yourself first.
#!/usr/bin/perl -w
use strict;
sub modify {
$_[0] = 'loser';
}
my $status = 'winner';
print "I am a $status\n";
modify( $status );
print "I am a $status\n";
__END__
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/