in reply to Very quick question about names in perl

For variables names that can be made lexical (that is, a 'my' can be put in front of it), names start with letters or underscore. Can't start with digits.

Package variables can consist of anything, as long as you write them in the form: ${"..."}. Otherwise, they have to start with letters or underscore (just like lexicals), *or* consist of a single punctuation character, *or* consist of numbers only. That is, $117 is a legal variable (but it's read-only), @117 is legal, but $17foo is not.

Abigail

  • Comment on Re: Very quick question about names in perl

Replies are listed 'Best First'.
Re: Re: Very quick question about names in perl
by dakedesu (Scribe) on Dec 15, 2003 at 13:11 UTC

    Thanks, but this raises more questions. What I plan on using this with, is to call functions that are part of an object, that will be read via $AUTOLOAD--would I be able to do something silly like $client->12('blah'), or would that be doing evil things?

      This is getting dangerously close to a philosphical discussion, but if you keep things simple, you'll have fewer things to worry about, and are therefore less likely to make mistakes. Speaking personally, I would limit myself to variables starting with letters and containing only letters, underscores and numbers. It makes the code easier to read (in theory), and you will spend less time later being confused. Assuming, of course, you are as easily confused as I am.

      --
      tbone1
      Ain't enough 'O's in 'stoopid' to describe that guy.
      - Dave "the King" Wilson

        You're probably correct, I need to rethink my design

      $client -> "12" ('blah');
      ought to work, but I don't have time right now to check.

      Abigail

Re: Re: Very quick question about names in perl
by tilly (Archbishop) on Dec 15, 2003 at 16:34 UTC
    There are also some special package variables like $^X. All of the ones that I know of, though, have established internal meanings.
      Those are usually considered to be punctuation variables as well.

      Abigail

        Yes, they are called that. But they don't consist of a single punctuation character and so were not included in your listing.