From all that I read when using Perl modules, the main use is:
- A module file with the extension
.pm , which includes the package <name> operator, where <name> is the name of the module file without the extension. - The code file that the module uses contains the
use <name>; statement use <name>; .
In the application, I have one main script code that uses about 5 modules. I forgot to include the package <name> statement in the modules, but my code still did a great job with the use <name> statement. I started getting Undefined subroutine errors with one of the modules, so I added the package instruction to each of the modules. Now the rest of these modules are stopped. What gives?
Example:
mainapp.pl
#!/usr/bin/perl use UtyDate; my $rowDate = CurrentDate("YYYYMMDD");
UtyDate.pm
#!/usr/bin/perl package UtyDate; sub CurrentDate {
When I run the above code, I get an Undefined subroutine &main::CurrentDate called at... error. However, if I remove the line package UtyDate; from UtyDate.pm, I will not get an error. This situation exists for several, but not all of my modules.
Obviously, I donβt show much more code, but I am confused about how any of the code that I donβt show can affect the package / usage constructs that I showed here.
perl perl-module
brydgesk
source share