[sf-perl] global symbol requires explicit package

David Alban extasia at extasia.org
Thu Apr 8 14:31:21 PDT 2010


strange...  when i change:

     defined $cleanup_routine and &{ $cleanup_subroutine }();

to:

     &{ $cleanup_subroutine }();

it compiles.

i want the defined test in there in case the package user undef's
$cleanup_subroutine.

On Thu, Apr 8, 2010 at 2:16 PM, David Alban <extasia at extasia.org> wrote:
>     1  package foo;
>     2
>     3  use strict;
>     4  use warnings;
>     5
>     6  BEGIN {
>     7    use Exporter   ();
>     8    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
>     9    $VERSION = do { my @r = (q$Revision: 1.4 $ =~ /\d+/g);
> sprintf "%d."."%02d" x $#r, @r };
>    10    @ISA         = qw( Exporter );
>    11    @EXPORT      = qw(
>    12                       $cleanup_subroutine
>    13                     );
>    14    @EXPORT_OK   = qw();
>    15  }
>    16  our @EXPORT_OK;
>    17
>    18  our $cleanup_subroutine = sub { return 1; };
>    19
>    20  sub foo_die ( @ ) {
>    21    defined $cleanup_routine and &{ $cleanup_subroutine }();
>    22    exit 255;
>    23  } # foo_die
>    24
>    25  1;

-- 
Live in a world of your own, but always welcome visitors.


More information about the SanFrancisco-pm mailing list