Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: Exporting scalars from a module

by chip (Curate)
on May 03, 2004 at 15:32 UTC ( #350048=note: print w/ replies, xml ) Need Help??


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


Comment on Re: Re: Exporting scalars from a module
Download Code
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. :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://350048]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (16)
As of 2014-08-27 14:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (239 votes), past polls