in reply to Re: managing constants created with constant.pm
in thread managing constants created with constant.pm

The OP was using constants correctly. She's just using a modern version of Perl.

Abigail

  • Comment on Re: managing constants created with constant.pm

Replies are listed 'Best First'.
Re: Re: managing constants created with constant.pm
by Zaxo (Archbishop) on Jul 14, 2003 at 08:50 UTC

    In 5.8.1, $ perl -e'use constant { FOO = 1, BAR = 2}; print FOO,BAR' does not compile. With stringy commas, the combined form does work,

    $ perl -e'use constant { FOO => 1, BAR => 2}; print FOO,BAR' 12$
    '1' and '3' are not legal names for subs.

    After Compline,
    Zaxo

      You are right about the stringification (I missed that), but your post suggested the hashref as only argument was incorrect, and that you need a use constant for each constant used.

      Abigail

Re: Re: managing constants created with constant.pm
by bakunin (Scribe) on Jul 14, 2003 at 09:16 UTC
    Abigail, I'm male!! :))))))))
    And folks, please forget about the syntax!! Everything I code with constants work( as you all pointed out), and thanks :))))
    The question still remains unanswered! Any ideas?? I know how to solve the problem. I just have a feeling that it is not the perl way!
    Ogla
      Hi,

      Abigail, I'm male!! :))))))))

      Am I they only monk who couldn't help but laugh at the irony here. :-)

      cheers

      thinker
      oh, by the way, I didn't like the line "... constants don't do what you think they do" Please be more specific.
      And in a 4000 line OO environment, I think, they exactly do what I expect them to do. OK, you can check ming SWF library, and maybe see my point of view.
      http://ming.sourceforge.net
      The constants are used as "FLAGS". This is very neat in my opinion. And one should have way to manage these flags. That's all I'm asking.