Kevin Christopher wrote at Wed, 05 Jun 2002 04:58:38 +0200:
> Yes, you can call subroutines either way, with or without the "&". The only case
>when the
> subroutine must be prefixed with an ampersand is, I believe, when you're assigning a
>reference
> variable, eg:
>
> $reference_x = \&subroutine_y;
>
> But that's another story.
>
Oh, I'm afraid that's not the truth :-)
&subroutine without any arguments calls the subroutine with the implicit @_ array,
while subroutine only calls subroutine() without any argument.
Look at this snippet:
@_ = qw(A B C);
print 'foo:'; foo; print "\n";
print '&foo:'; &foo; print "\n";
sub foo {
print @_;
}
It prints:
foo:
&foo:ABC
Greetings,
Janek
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]