[tpm] Lightning Talk lineup

Alexandru Capsa alexcapsa at gmail.com
Fri Oct 3 12:01:45 PDT 2008


Well, when you have to call a method defined later in the source file you
have to use '&' or use the brackets. Example:

package foo;

sub my_method {
    my $b = some_method;
}
sub some_method {
    return "something";
}

The above will fail, Perl will think of "some_method" as just another bare
word. But if you write:

my $b = &some_method;
or
my $b = some_method();

everything will work. Of course, you can also define some_method before
my_method.

Cheers,
Alex


On Fri, Oct 3, 2008 at 2:20 PM, Dave Doyle <dave.s.doyle at gmail.com> wrote:

> ...
>
> Dammit.
>
>
> On Fri, Oct 3, 2008 at 1:39 PM, Richard Dice <rdice at pobox.com> wrote:
>
>>
>>>
>>> But then Richard broke my head with:
>>>
>>> sub a {
>>>     &b
>>> }
>>>
>>
>> Jon Orwant schooled me with this one back in '97.
>>
>>
>>> My jaw literally hit the table.  I'd also not know the & invocation style
>>> (without brackets) automatically passed @_ into the sub.  I'd thought that &
>>> is soooo Perl 4 and beneath my notice.  Whoops.  Two characters.  Two bloody
>>> characters to my 21.
>>>
>>
>> Of course, '&' is necessary when defererencing a coderef, but the context
>> is different I'll admit.
>>
>>
>>> Got the job though. :)
>>>
>>
>> Yeah, about that.  We should talk...
>>
>> Cheers,
>>  - Richard
>>
>>
>
>
> --
> dave.s.doyle at gmail.com
>
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm
>
>


-- 
Alexandru Capsa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20081003/0d405fba/attachment.html>


More information about the toronto-pm mailing list