strict::ModuleName - verify that current package name matches filename


strict-ModuleName documentation  | view source Contained in the strict-ModuleName distribution.

Index


NAME

Top

strict::ModuleName -- verify that current package name matches filename

SYNOPSIS

Top

    # 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.

DESCRIPTION

Top

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.

NOTES

Top

Maybe this module should just warn() more instead of die()ing?

COPYRIGHT

Top

AUTHOR

Top

Sean M. Burke sburke@cpan.org


strict-ModuleName documentation  | view source Contained in the strict-ModuleName distribution.