Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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

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. :-)

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 imbibing at the Monastery: (7)
As of 2016-10-01 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (8 votes). Check out past polls.