in reply to global variables defined in an external file

Really, the question to ask is how many are the global variables? I know it's good practice not Export variables, but if it must be done, you can do: The pm file:

package Def; use warnings; use strict; use vars qw(@ISA @EXPORT $foo $bar $boo); BEGIN{ require Exporter; Exporter->import(); } @ISA = qw(Exporter); @EXPORT = qw($foo $bar $boo); 1;
The file which uses the pm file
#!/usr/bin/perl use warnings; use strict; use Def; # the variable defined module $foo = 'you can\'t foo me'; $bar = 'Let\'t meet in the bar'; $boo = 'The fans boo you today'; print $boo,$foo,$bar;

Replies are listed 'Best First'.
Re^2: global variables defined in an external file
by choroba (Cardinal) on May 06, 2013 at 15:58 UTC
    It is the ohter way round:

    Def.pm:

    package Def; use warnings; use strict; use Exporter 'import'; our @EXPORT = qw/$sc @ar %ha/; our $sc = 'All'; our @ar = qw/the variables/; our %ha = (exported => ' succesfully.'); __PACKAGE__
    The script:
    #!/usr/bin/perl use warnings; use strict; use Def; print "$sc @ar ", %ha;
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^2: global variables defined in an external file
by fionbarr (Friar) on May 06, 2013 at 15:52 UTC
    thanks for your very clear response....however, I'd like to do this
    $foo = 'you can\'t foo me'; $bar = 'Let\'t meet in the bar'; $boo = 'The fans boo you today';
    in the module and reference these variables in the calling program as: print $boo, etc.