[Melbourne-pm] $a $b $c

Tim Connors tconnors+pmmelb at astro.swin.edu.au
Fri Aug 13 08:34:47 CDT 2004


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.

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.

If I remove log10 from the mycommon.pm altogether, then perl complains no
such routine being defined. If I simply remove the definition from
mycommon.pm, but still keep it in @EXPORT and @EXPORT_OK, then all works
fine.

Maybe perl has defined a log10, but someone forgot to @EXPORT it?


-- 
TimC -- http://astronomy.swin.edu.au/staff/tconnors/
Just don't create a file called -rf.  :-)
        -- Larry Wall in <11393 at jpl-devvax.JPL.NASA.GOV>


More information about the Melbourne-pm mailing list