I have different versions of a module, say Utils1.pm and Utils2.pm with different filenames but they all have the same package name. I want a .pl file to be able to use whatever version it wants.
Here's the module:
package Utils; use strict; use warnings; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(Log); # symbols to export on request sub Log { my $message = shift; print STDERR "$message\n"; } # Note that Log() is also called from the Utils namespace: sub Start_app { Log("App started."); # Handle other stuff } 1;
And it exports a few functions that are used at many points int the code. Because the function is used so many places, I want to improve readability by not explicitly referencing the package in app.pl.
Then we have the app.pl:
#This file: app.pl use strict; use warnings; use Utils1; Log("App started");
But I get this when running it:
How do I get Log() imported into main? TIA$ perl app.pl Undefined subroutine &main::Log called at app.pl line 8. $
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |