Eric Roode wrote:
> 
> Steve Fink, via the Perl6 Librarian, wrote:
> >=head2 EXAMPLE
> >
> >    1 my ($x, $y, $z, $r);
> >    2 $z = 1;
> >    3 f(\$r);
> >    4 my $logfile = "/tmp/log";
> >    5 $x = 1 if cond();
> >    6 print $x+$y;
> >    7 undef $z;
> >    8 print $z;
> >
> [...]
> >No warning is issued for C<$r> because any variable whose reference is
> >taken may be used and/or assign to through the reference.
> 
> Perl is not C.  Perl passes parameters to subroutines by reference.
> Example:
>         sub initialize_to_seven
>         {
>             $_ = 7  foreach @_;
>         }
> 
>         my ($a, $b, $c);
>         initialize_to_seven ($a, $b, $c);
>         print "$a, $b, $c\n";

Right. Thank you.

Lines 2 & 3 should be combined to $z = \$r (I just wanted to take a
reference in something besides void context!), and passing a variable to
a function should be treated as both a use and a definition.

Reply via email to