Ok, I have a main script and a module I wrote, I will simplify to see if you can help.
<---------- MAIN SCRIPT ---------->
!/usr/bin/perl
use strict;
use myPM;
my $var = 'Hello World';
say_hi();
<---------- myPM SCRIPT ---------->
package myPM;
use strict;
require Exporter;
our @ISA = qw (Exporter);
our @EXPORT = qw (say_hi);
sub say_hi {
print $main::var . "\n";
}
1;
I would hope this would print 'Hello World' but it prints nothing. Everything calls right, I have confirmed that the actual fucntion is being called etc. However, I just seem to have the syntax of the main::var thing wrong. Any help would be greatly appreciated.
<---------- MAIN SCRIPT ---------->
!/usr/bin/perl
use strict;
use myPM;
my $var = 'Hello World';
say_hi();
<---------- myPM SCRIPT ---------->
package myPM;
use strict;
require Exporter;
our @ISA = qw (Exporter);
our @EXPORT = qw (say_hi);
sub say_hi {
print $main::var . "\n";
}
1;
I would hope this would print 'Hello World' but it prints nothing. Everything calls right, I have confirmed that the actual fucntion is being called etc. However, I just seem to have the syntax of the main::var thing wrong. Any help would be greatly appreciated.