in reply to single quote in package variable names

From perlmod:

The old package delimiter was a single quote, but double colon is now the preferred delimiter, in part because it's more readable to humans, and in part because it's more readable to emacs macros. It also makes C++ programmers feel like they know what's going on--as opposed to using the single quote as separator, which was there to make Ada programmers feel like they knew what was going on. Because the old-fashioned syntax is still supported for backwards compatibility, if you try to use a string like "This is $owner's house", you'll be accessing $owner::s; that is, the $s variable in package "owner", which is probably not what you meant. Use braces to disambiguate, as in "This is ${owner}'s house".

Cheers,
Ovid

New address of my CGI Course.

  • Comment on Re: single quote in package variable names

Replies are listed 'Best First'.
Re^2: single quote in package variable names
by Fletch (Bishop) on Nov 14, 2006 at 18:20 UTC

    And that's referenced right in the middle of the second paragraph of perldata:

    ... In some cases, it may be a chain of identifiers, separated by "::" (or by the slightly archaic "'"); all but the last are interpreted as names of packages, to locate the namespace in which to look up the final identifier (see "Packages" in perlmod for details).