[sf-perl] Meaning of an asterisk (*)
nheller at silcon.com
nheller at silcon.com
Tue Feb 26 13:07:21 PST 2008
Thank you for your response.
You said that the final block of code was an error.
How would you change it so that it is well-written?
>> can_ok( $song, 'player');
>>
>> {
>> package SongPlayer;
>> use subs 'system';
>> package main;
>> my $fail = 0;
>> my @args;
>>
>> *SongPlayer::system = sub;
>> {
>> @args = @_;
>> return $fail;
>> };
>>
>> 4. For that matter, what is the meaning of this entire line, and why
>> are
>> the lines below it set into a block by braces?
>
> This is a bug. The code meant to define an anonymous subroutine that
> does stuff (and then gets aliased as 'system' in the 'SongPlayer'
> package), but the semicolon after 'sub' creates an empty anonymous
> subroutine that does nothing, plus a section of code that will be run
> at the end of the script (rather than when it gets called).
>
> Garth
More information about the SanFrancisco-pm
mailing list