I'm having trouble properly using %EXPORT_TAGS in my Perl module. In Solver.pl I have:
use MatrixFunctions qw(:Normal);
Then inside MatrixFunctions.pm, I have:
package MatrixFunctions;
use strict;
use Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
$VERSION = 1.00;
@ISA = qw(Exporter);
@EXPORT = ();
@EXPORT_OK = qw(&det &identityMatrix &matrixAdd
&matrixScalarMultiply &matrixMultiplication);
%EXPORT_TAGS = ( Det => [qw(&det)],
Normal => [qw(&det &identityMatrix &matrixAdd
&matrixScalarMultiply &matrixMultiplication)]);
However it only works when I have @EXPORT_OK including all the methods. If I have
@EXPORT_OK = ();
I have the error:
"matrixScalarMultiply" is not exported by the MatrixFunctions module
"det" is not exported by the MatrixFunctions module
"matrixAdd" is not exported by the MatrixFunctions module
"matrixMultiplication" is not exported by the MatrixFunctions module
"identityMatrix" is not exported by the MatrixFunctions module
Can't continue after import errors at Solver.pl line 6.
BEGIN failed--compilation aborted at Solver.pl line 6.
The point of using qw(:Normal)
in my Solver.pl file is so that I can have @EXPORT_OK empty I thought. What am I doing wrong?
perldoc -f Exporter
under the Advanced Features section:The bolded section above explains that you are required to have the functions you wish to place in
%EXPORT_TAGS
in either@EXPORT_OK
or@EXPORT
A pattern that I have started using is to defined everything that I want to allow to be exported in
@EXPORT_OK
, then use@EXPORT_OK
to build an `:all' tag: