When you encounter things like this in the future, the Debugger is very useful. In particular, look at the X vars... (or V Package::Name vars...) commands. Try, for example,

DB<1> X OBJECT $OBJECT = 123

There's nothing special about constants. All that constant.pm does is create a method in the package that returns the value you gave, by cleverly using import through use. Here's the relevant parts from constant.pm in 5.12.3:

#===================================================================== +== # import() - import symbols into user's namespace # # What we actually do is define a function in the caller's namespace # which returns the value. The function we create will normally # be inlined as a constant, thereby avoiding further sub calling # overhead. #===================================================================== +== sub import { #... #note: $full_name is set to "Package_I_Was_Called_From::ConstantNa +me", for each constant you provide #if you have a scalar, it basically does *$full_name = sub () { $scalar }; #and if you have an array: *$full_name = sub () { @list }; #... }

Note: In the debugger output above, you may have noticed that it appeared as a regular variable. Indeed, in Perl 5.8 (as I understand it), constant.pm had some magic added to it so that scalars are simply added into the symbol table, appearing to be a package variable. Still, you can't really use them as variables, as you can observe here:

DB<6> x &OBJECT 0 123 DB<7> x $OBJECT 0 undef
-Thomas
"Excuse me for butting in, but I'm interrupt-driven..."

In reply to Re: What does @_[OBJECT, ARG0, ARG1] mean? by thomas895
in thread What does @_[OBJECT, ARG0, ARG1] mean? by neilwatson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.