[Melbourne-pm] $a $b $c

Sisyphus kalinabears at iinet.net.au
Fri Aug 13 18:25:19 CDT 2004

Tim Connors wrote:
> On Fri, 13 Aug 2004, Joshua Goodall wrote:
>>Slightly amused by:
>>[529] joshua at green:~$ perl -le 'use strict; $a = 42;'
>>[529] joshua at green:~$ perl -le 'use strict; $b = 101;'
>>[530] joshua at green:~$ perl -le 'use strict; $c = 3.141;'
>>Global symbol "$c" requires explicit package name at -e line 1.
>>Execution of -e aborted due to compilation errors.
>>This probably has something to do with sort BLOCK, doesn't it?
>>perlfunc -f sort alludes to $a / $b being package variables,
>>but I'd always assumed it was black magic for 'sort BLOCK' only.

The special status of $a and $b extends beyond the 'sort' block .... as 
you have just demonstrated :-)

I don't know the details, but I guess that it's impractical and/or 
undesirable to limit that special status to a 'sort' block only.

> I was amused and then annoyed today, when I noticed in all of my perl
> scripts that
> use 'mycommon';
> and perl -w:
> complained with:
> Subroutine log10 redefined at /home/office/tconnors/perllib/mycommon.pm line 118.
> It turns out that despite the manpage (perlfunc) not saying anything about
> log10, if I have my own "sub log10" in mycommon.pm, in @EXPORT, then perl
> complains about log10 being redefined.

Hmmm .... there's no such problem with a module that defines and exports 
a 'log10' subroutine on *my* perl.

Are you sure you haven't defined the sub twice in 'mycommon.pm' ?


More information about the Melbourne-pm mailing list