On Wed, Aug 5, 2009 at 05:21, Dermot<[email protected]> wrote:
> 2009/8/5 Chas. Owens <[email protected]>:
>> On Tue, Aug 4, 2009 at 23:07, Dave Tang<[email protected]> wrote:
>>> On Wed, 05 Aug 2009 12:55:22 +1000, Chas. Owens <[email protected]>
>>> wrote:
>>>
>>> snip
>
> Here's someone's recent experience of encountering prototypes:
>
> http://perlhacks.com/2009/06/what-is-wrong-with-this-picture.php
>
> Good luck,
> Dp.
>
Yes, calling a function with & at the beginning will bypass a
prototype. So will calling it via a reference (which means prototypes
mean nothing the OO Perl):
#!/usr/bin/perl
use strict;
use warnings;
#one $ means this is a unary function (i.e. it takes one scalar)
sub foo ($) {
print join("::", @_), "\n";
}
eval "foo(1, 2); 1"; #this will fail because we are passing in two arguments
print $@;
my $coderef = \&foo;
$coderef->(1, 2, 3); #but this succeeds no problem
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/