John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:

Working on Exporter::VA, I realized that I could export file handles too. The code will use a regex to check and strip the leading sigil, using a character class, then use the found char as a hash lookup.

So, introducing a one-character sigil for file handles, I could trivially support that with no extra overhead.

E.g. use ModuleName v2.3.1 qw/foo $x %hash ^LOG/; if I decide to make ^ my pseudo-sigil. I already use a - for pragmas and a : for tags, and reserve + for user extension.

So, what character should I use? As long as it's not any of those or something that can be in an identifier name, anything will work.

Perhaps it can use some strange Unicode character that nobody would ever use for anything else? "\N{REFERENCE MARK}LOG" doesn't look half bad...

—John

update (broquaint): changed title

Replies are listed 'Best First'.
(tye)Re: ...beause I can
by tye (Sage) on Nov 01, 2002 at 20:25 UTC

    Don't you just want to use "*" since file handles are always passed around as part of a symbol-table glob?

            - tye
      No, because the * sigil really will import the entire glob. Hmm, maybe a configuration flag could mean that * imports the IO only, not the whole glob, since that's what is normally used.

        *LOG would have been my choice, too; but then I only ever use that when I'm after a file handle and rarely worry myself with the rest of the glob.

        Perhaps <LOG> instead? It'd require a little bit extra to remove the trailing '>', but should be pretty obvious about what it does.

            --k.


Re: ...beause I can
by particle (Vicar) on Nov 01, 2002 at 20:58 UTC

    what about something more perlish, like *LOG{IO}? for that matter, will something like *LOG{CODE} work properly? it would be nice if it did.

    ~Particle *accelerates*

Re: ...beause I can
by false (Novice) on Nov 01, 2002 at 21:47 UTC

    I like the looks of >LOG or /LOG because either are associated with files.

    As an alternative, #LOG could be used. (Commodore BASIC uses the # to represent a file descriptor :)

    -- false

      Using # at the start of a word inside a qw-quotelike produces a warning. (Some people might be expecting it to be treated as a comment, and Perl warns them it isn't.)

      Makeshifts last the longest.

      #LOG could be used

      Could that break code related to comments? Is '#' used for anything other than comments?