in reply to Re: global variables defined in an external file
in thread global variables defined in an external file

use strict; use warnings; package x; use Exporter; my $VERSION = 1.00; my @EXPORT = (); my @ISA = qw(Exporter); my $a_template = "a12 a1 a4 a11 a2 a10 a12 a20 a15 a15 a1 a10 a1 a1 a +1 a2 a2 a1 a3 a3 a9 a1 a15 a2"; @EXPORT = qw(xxx $a_template); sub xxx {print "in package x\n";} 1;

Replies are listed 'Best First'.
Re^3: global variables defined in an external file
by NetWallah (Canon) on May 07, 2013 at 03:49 UTC
    In addition to aitap's correction, I would recommend that you follow Exporter's advice:
    Exporting variables is not a good idea. They can change under the hood, provoking horrible effects at-a-distance, that are too hard to track and to fix. Trust me: they are not worth it.

    To provide the capability to set/get class-wide settings, it is best instead to provide accessors as subroutines or class methods instead.

                 "I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
            -- Dr. Cox, Scrubs

Re^3: global variables defined in an external file
by aitap (Curate) on May 06, 2013 at 17:20 UTC

    my creates a block-scoped variable, while you need to create (using vars or our, as already suggested) a package-scoped variable (available in the symbol table), so it actually can be exported.

    Read Coping with Scoping for more information on this topic.