strict::ModuleName -- verify that current package name matches filename
# In a file (some @INC dir)/Shazbot.pm: package Shazbot; use strict::ModuleName; # does nothing, because Shazbot.pm matches package name "Shazbot"
That does nothing, because the package name "Shazbot" is exactly what you'd expect from "Shazbot.pm" in an @INC directory.
But any of these will throw a fatal error:
# In a file (some @INC dir)/Shazbot.pm: package ShazBot; use strict::ModuleName; # that's a fatal error, because Shazbot isn't ShazBot # In a file (some @INC dir)/Shazbot.pm: package Shaz::Bot; use strict::ModuleName; # that's a fatal error, because Shazbot isn't Shaz::Bot # In a file (not any @INC dir)/Shazbot.pm: package Shazbot; use strict::ModuleName; # That's a fatal error, because ShazBot wasn't findable # via any @INC dir.
This module stops you from having your module's filename and package name disagree, such as might happen as you're changing the name as you're developing the module; or such as might happen if you are using a case insensitive filesystem, and get the case wrong in the filename.
A line saying use strict::ModuleName; in a module is basically an compile-time assertion that the current package name is compatible with the filename which the current source is being read from.
use strict::ModuleName;
Maybe this module should just warn() more instead of die()ing?
I consider this current version an alpha, and its interface is not yet settled upon. Do email me if you have any opinions about how it works. If I receive no feedback, I'll just rerelease it as the final version after a while.
Copyright (c) 2002 Sean M. Burke. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The programs and documentation in this dist are distributed in the hope that they will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
Sean M. Burke sburke@cpan.org
sburke@cpan.org
To install strict::ModuleName, copy and paste the appropriate command in to your terminal.
cpanm
cpanm strict::ModuleName
CPAN shell
perl -MCPAN -e shell install strict::ModuleName
For more information on module installation, please visit the detailed CPAN module installation guide.