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

G'day ikegami,

Thanks for the feedback. As mentioned, this is for a $work project, which has various contraints, so some of these "exotic" forms wouldn't come up anyway. Quickly working through the list:

  1. I'm familiar with "::" but it wouldn't pass code review (cleverness reducing readability). It would need to be changed to "package main".
  2. While "_a" probably wouldn't pass code review (non-meaningful name) it does match the pattern: I added it the original code and got "ok 8 - Testing _a". I do use names with a leading undersore in t/name.t scripts: typically prepending Some::Work::Module with _Test::, _Mock::, or similar.
  3. As already stated, non-ASCII names are disallowed ($work constraint).
  4. Like you, I wouldn't have considered "aaaa::::::bbbb" to be valid. It wouldn't pass code review. Possibly flagged with "too damn weird; are you drunk?". :-)

— Ken

Replies are listed 'Best First'.
Re^3: Is there an official regex for checking module names?
by ikegami (Patriarch) on Feb 09, 2022 at 00:13 UTC

    I'm familiar with "::" but it wouldn't pass code review (cleverness reducing readability)

    No, it's not being clever.

    Do you write package main::Foo::Bar; or package Foo::Bar;? So why do you expect me to use %main:: instead of %::? If I want the root namespace, that's what I use. Not some alias created so you can say "scripts run in main".

    Also, using Foo::->method instead of Foo->method solves a real problem. Again, not cleverness.

    While "_a" probably wouldn't pass code review (non-meaningful name) it does match the pattern

    oops! I saw the pattern for the lead character was shorter, and I somehow imagined that "_" wasn't included.

    As already stated, non-ASCII names are disallowed ($work constraint).

    That was not mentioned in the question. And you're not the only person using PerlMonks.

      I believe you have taken my comment about "::" completely out of context. You wrote "package ::" which is very obscure — I actually don't think I've seen it previously — for $work, I'd expect "package main", which is common and generally understood.

      "So why do you expect me to use %main:: instead of %::?"

      I've no idea where that comes from. I did not voice such an expectation of you or anyone else.

      "Also, using Foo::->method ..."

      Again, I've no idea where that comes from; it wasn't mentioned in my post. In fact, I encourage the use of "::->" over just "->".

      "That was not mentioned in the question."

      My reply to you had "As mentioned, ...".

      "And you're not the only person using PerlMonks."

      Why write that?

      — Ken

        I've no idea where that comes from.

        You said using package :: wouldn't pass review. («I'm familiar with "::" but it wouldn't pass code review») So it means that %:: wouldn't pass review.

        Again, I've no idea where that comes from; it wasn't mentioned in my post.

        True, but you said :: and aaaa::::::bbbb wouldn't pass review, so I extrapolated that Foo:: wouldn't either.

        Why write that?

        The comment to which I replied assumed replies to your posts are only for your benefit.

        My reply to you had "As mentioned, ...".

        And I said that that this is irrelevant. Not everything is about you. You asked how to check if something is legitimate package name, and that was an important part of that.