I have a perl program that tries to call a subroutine which is available through a require statement. The file is called headers.pl and contains nothing more than a single subroutine called header_print that takes no arguments and just does a print, something like ....
sub header_print {
...
}
1;
My main perl is:
#!/usr/bin/perl
use CGI qw
standard);
use lib qw(.);
eval { require "headers.pl"};
if ($@) {
print "Failed to load require because: $@"
}
else
{
print "No problem with require";
}
header_print{};
When the perl runs I successfully get the "No problem with require" suggesting the require worked file but then the perl fails with..
"Can't call method "header_print" without a package or object reference at ...pathname... line 12
--------
I am a bit of a beginner at this so I am hoping this is something obvious.
Thanks in anticipation.
sub header_print {
...
}
1;
My main perl is:
#!/usr/bin/perl
use CGI qw
use lib qw(.);
eval { require "headers.pl"};
if ($@) {
print "Failed to load require because: $@"
}
else
{
print "No problem with require";
}
header_print{};
When the perl runs I successfully get the "No problem with require" suggesting the require worked file but then the perl fails with..
"Can't call method "header_print" without a package or object reference at ...pathname... line 12
--------
I am a bit of a beginner at this so I am hoping this is something obvious.
Thanks in anticipation.