How do I export a package symbol to a namespace in Perl?
- by Mike
I'm having trouble understanding how to export a package symbol to a namespace. I've followed the documentation almost identically, but it seems to not know about any of the exporting symbols.
mod.pm
#!/usr/bin/perl
package mod;
use strict;
use warnings;
require Exporter;
@ISA = qw(Exporter);
@EXPORT=qw($a);
our $a=(1);
1;
test.pl
$ cat test.pl
#!/usr/bin/perl
use mod;
print($a);
This is the result of running it
$ ./test.pl
Global symbol "@ISA" requires explicit package name at mod.pm line 10.
Global symbol "@EXPORT" requires explicit package name at mod.pm line 11.
Compilation failed in require at ./test.pl line 3.
BEGIN failed--compilation aborted at ./test.pl line 3.
$ perl -version
This is perl, v5.8.4 built for sun4-solaris-64int