in reply to Re^2: Use module only if it is in use
in thread Use a module only if it is in use

Is it safe to asume that double colons in module names get always translated into slashes ("::" -> "/") instead of backslashes or whatever is used by the OS for subdirs?
No, it's not safe to assume that. And be lucky. Your code wouldn't work if Perl changed the '::' to a '/', because that it would try to divide M by hello("again"), which most likely results in an error.

Perl maps '::' to the appropriate directory separator when it's used as a bareword argument to use and require. But that isn't always.

Replies are listed 'Best First'.
Re^4: Use module only if it is in use
by bart (Canon) on Sep 02, 2009 at 18:32 UTC
    Is it safe to asume that double colons in module names get always translated into slashes ("::" -> "/") instead of backslashes or whatever is used by the OS for subdirs?
    No, it's not safe to assume that.

    IMO it is safe to assume that for checking %INC. It always worked on MacPerl, on the pre OSX Macintosh, where the system's path separator is a ":". It most definitely is safe on Windows perls, too. If there are exceptions, I haven't heard of them, yet.

      VMS would be the other non-unix system, and it uses "/" as well, as far as I can remember.

      Core modules such as if rely on "/" being the separator.

Re^4: Use module only if it is in use
by ikegami (Patriarch) on Sep 02, 2009 at 16:08 UTC
    He was asking if the keys of %INC use / instead of :: across all systems, and the answer is yes.
Re^4: Use module only if it is in use
by vitoco (Hermit) on Sep 02, 2009 at 16:08 UTC

    I meant as a key for %INC, not as barewords:

    $text = Text::Unidecode::unidecode($text) if $INC{"Text/Unidecode.pm"};