in reply to Re: Underscore in scalar name not in main package
in thread Underscore in scalar name not in main package

You are well read and astute. The text did not say that exactly but I inferred it from the following text:

Perl identifiers that begin with digits or punctuation characters are +exempt from the effects of the package declaration and are always for +ced to be in package main

So the question that left me with was, 'what exactly is considered a punctuation character?'

The history of the underscore has a lot to do with typewriters -- it was apparently the key people used to use to underscore words. However, that history is irrelevant to how we use it today. When I visit thesaurus.com:

Punctuation is the act or system of using specific marks or symbols in + writing to separate different elements from each other or to make wr +iting more clear.

My use, and the question, was in line with this definition. I've seen people use underscores in method names to tell others that 'this method is private -- do not use it.' So the question is perfectly valid -- how does one do the same thing with a variable? I figured I would try an underscore and I got a weird behavior.

Celebrate Intellectual Diversity

Replies are listed 'Best First'.
Re^3: Underscore in scalar name not in main package
by dave_the_m (Monsignor) on May 11, 2026 at 06:39 UTC
    So the question that left me with was, 'what exactly is considered a punctuation character?'
    The first two paragraphs of perlvar say, in part:
    Variable names in Perl can have several formats. Usually, they must begin with a letter or underscore ...

    Perl variable names may also be a sequence of digits, a single punctuation character, or ...
    I think its unambiguous from that opening that an underscore is grouped with letters rather than punctuation characters.

    Dave.

Re^3: Underscore in scalar name not in main package
by LanX (Saint) on May 10, 2026 at 23:19 UTC
    I'd say punctuation characters are those you can use in place of a point.°

    So . , ; : ! ? ¿ etc...

    Anyway I think this phrasing is lacking perlvar lists some special variables which are not punctuation but global, like $@ or %INC

    Update

    So that's the definition I found online, wider than I thought but clearly not covering @

      Punctuation characters are symbols used in writing to clarify meaning and indicate pauses or stops. The 14 primary punctuation marks in English include the period, comma, question mark, exclamation point, colon, semicolon, dash, hyphen, parentheses, brackets, braces, apostrophe, quotation marks, and ellipsis.

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

    °) "Punkt" is point in German, so it may be more obvious for me, "point" is most probably a French "mutant" of a Latin word like "punctum"