in reply to Re: Is there an official regex for checking module names?
in thread Is there an official regex for checking module names?

> I wouldn't consider the final one valid (even though it was accepted).

It was accepted as package name, but as a module it would hit a wall, ° since :: are translated to path delimiter /

DB<83> use a::::b Can't locate a//b.pm in @INC

I'm not sure if there are any file-systems with semantics for an unnamed directory between two '/', win at least gives me a hard time trying to create a directory with an empty string as name.

But I'm wondering if this might have some relevance as vulnerability, since I remember seeing sequences of // as special syntax for network resources.

update

°) It's possible on win at least, because it translates multiple / to no-ops, hence a//b is the same like a/b

so I created

C:\tmp\x\y>echo warn 'inside';1 >z.pm

started the debugger and ran

DB<5> use lib '.' DB<6> use x::::y::::z inside at x//y///z.pm line 1.

It also reveals a trick to force a recompile of a module by adding more :: to the path.

Like that Perl won't find it cached in %INC and try to require it again.

DB<7> use x::::y::::z DB<8> use x::::y::::::z inside at x//y///z.pm line 1. at x//y///z.pm line 1.

DISCLAIMER: Too lazy to test this with linux (shame on me) and the rest of perlport... (no amiga handy...)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^3: Is there an official regex for checking module names?
by choroba (Cardinal) on Feb 08, 2022 at 23:26 UTC
    At least on Linux, for existing modules it works as if just one pair of colons was specified:
    main::(-e:1): 1 DB<1> use Time::::Piece;

    But it loads the package that's declared in the file under its correct name:

    DB<2> x Time::::Piece::localtime->ymd; Can't locate object method "ymd" via package "Time::::Piece::localtime +" (perhaps you forgot to load "Time::::Piece::localtime"?) at (eval 7 +)[/usr/lib/perl5/5.26.1/perl5db.pl:738] line 2. DB<3> x Time::Piece::localtime->ymd; 0 '2022-02-09'

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      Our brains are in sync again, see my update for win... ;-)

      I'm wondering if there is an OS-agnostic rule to reduce // to /

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        Not leading ones for Windows. If you include the path portions of URLs, then it might not be safe there either.

Re^3: Is there an official regex for checking module names? (updated)
by ikegami (Patriarch) on Feb 09, 2022 at 00:27 UTC

    I remember seeing sequences of // as special syntax for network resources.

    In Windows // aka \\ is significant at the start of a path.

    • \\server\share
      • \\localhost\c$ (C:\)
      • \\wsl
      • \\server\pipe\name
    • \\?\C:\foo Long path
    • more

    Too lazy to test this with linux

    // is the same as / there.