Hi, keepers of Perl knowledge!
I have code where I am constructing the name of a .conf file based on the location of the module:
package Module; use warnings; BEGIN { my $pathname = $INC{$\(__PACKAGE__)}.pm"}; $pathname =~ s/\.pm$/.conf/; } 1;
When I check the syntax via the interpreter, I get a warning:
$ perl -c Module.pm Use of uninitialized value in substitution (s///) at Module.pm line 8. Module.pm syntax OK $
If I comment out the use warnings; pragma, the warning goes away.
I'm assuming that __PACKAGE__ is not defined until a script loads the module, so this might be an explanation. perlmod states that using __PACKAGE__ can be thorny when creating variable names, so I thought I would pose the question to you. Should I be looking at another method to construct a variable name?
Thanks!
In reply to a few questions about __PACKAGE__ by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |