i am trying to create a module which is like this
package MyModule;
use strict;
use Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
$VERSION = 1.00;
@ISA = qw(Exporter);
@EXPORT = qw(func1);
sub func1 {
my x = shift;
print x;
func2();
}
sub func2 {
print x;
}
and from a perl script, i am calling func1 of the module and passing a variable x. how do i make that variable visible to both subroutines or say all the functions inside that module.
Please help.
Declare
$xin the scope of the file usingmyorour:File has the largest lexical scope, so the variable will be visible for the rest of code (unless you re-declare it in some inner scope using
my).