in reply to Re: Using External Subroutines
in thread Using External Subroutines

Your config.pl should be made into a module and $name needs to be exported from config so that it is available in the calling script.
For more information see perlman:lib:Exporter, perlman:perlmodlib and perlman:perlmod.

So you will need to add code like
package ModuleName; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(...); # symbols to export by default

@EXPORT should contain the name of the variables and the subroutines you want to be able to access from calling scripts.
Also, your calling script should do a use ModuleName; rather than require ModuleName;

Replies are listed 'Best First'.
Re: Re: Re: Using External Subroutines
by Anonymous Monk on Nov 19, 2001 at 02:56 UTC
    is that really the only way to do it? no way to make variables global or anything ?
      well, if you want to do this and really, really want to avoid creating a proper module using exporter....

      You can do something like this:
      $name = \config::name;
      in your calling script. Note that $name cannot be declared by "my" in config.pl

      Again, I want to stress I would never use something like this. It is some much easier, simpler and safer to convert config.pl into a module and then use exporter to expose whatever you need.
      Of course you can,
      but maybe you'll get in trouble with global variables.
      For example, if you decide not to use strict and warnings, you won't declare your variables...

      You want this?
      Of course I don't in a "huge" set of scripts

      Cheers
      Hopes