http://www.perlmonks.org?node_id=350048


in reply to Re: Exporting scalars from a module
in thread Exporting scalars from a module

Rule #1 of programming: Repetition is evil.
my @xvars; BEGIN { @xvars = qw($PACKAGE_REQUEST_ID $BUGNUMBER $KBARTICLE $DISTMET +HOD $MINSP $MAXSP $ISNONINSTALLINGPKG $JOBBRANCHNAME $HOTPATCHBINARIE +S $BINARIESAFFECTED $BUGTITLE) } use vars ( qw(@ISA @EXPORT $VERSION), @xvars ); require Exporter; @ISA = qw(Exporter); @EXPORT = ( qw(Execute GetValue), @xvars );

    -- Chip Salzenberg, Free-Floating Agent of Chaos

Replies are listed 'Best First'.
Re^3: Exporting scalars from a module
by Anonymous Monk on Mar 19, 2005 at 01:55 UTC
    How can I enable use strict and not use my to declare the variables? (The version of perl we use does not support the our keyword):

    package ExitCode; my @varsToExport = qw(%exitCodes $EXIT_SUCCESS $EXIT_GENERAL_FAILURE $ +EXIT_CHANGELIST_CONSUMED $EXIT_FUTURE_CHANGELIST); require Exporter; use vars (qw(@ISA @EXPORT), @varsToExport); @ISA = qw(Exporter); @EXPORT = qw(@varsToExport); %exitCodes; # Define exit codes $EXIT_SUCCESS = 0;
      You need to put your @varsToExport in a BEGIN block.
      my @varsToExport; BEGIN { @varsToExport = qw(...); } use vars @varsToExport; @EXPORT = qw(@varsToExport);
      Or you can upgrade your perl. :-)