I'm having problems when I try to pass an argument to a subroutine
that I defined in a package that's in another file.
I defined the package as this:
package MyPackage_1;
# Set the Exporter so functions can be called in other areas
BEGIN
{
use Exporter();
@ISA = qw(Exporter);
@EXPORT = qw (&PrintVar);
}
sub PrintVar()
{
my $st = @_[0];
print "String: $$st \n";
return 1;
}
return 1;
<<
The package is in MyPackage_1.pm
I now call the PrintVar() function from my main script like this:
>> Code >>
#!/usr/bin/perl
# My own modules
use MyPackage_1;
my $teststring = "Hello there!";
$ret = Browser::PrintVar (\$teststring);
<<
The main script (above) is in a file called getPIN.pl
I try checking for syntax errors before executing so I issue a perl -c
against my file. The MyPackage_1.pm file compiles correctly but I get
an error against the getPIN.pl file:
root@Ubuntu:/home/perl# perl -c getPIN.pl
Too many arguments for MyPackage_1::PrintVar at getPIN.pl line 90,
near "$teststring)"
What am I doing wrong here? Can I pass arguments thru the stack "@_"
to PrintVar() as if it was a subroutine defined in the main perl file?
Thanx,
Baba