BTW, the Devel:: namespace isn't right for this. Devel:: is for
development-time tools, not run-time.
Tim.
On Tue, Oct 09, 2001 at 08:23:12PM -0600, chromatic wrote:
> On Tuesday 09 October 2001 20:17, Kirrily Robert wrote:
>
> > > Devel::Constants captures constant declarations (with the constant
> > > pragma), allowing values to be resolved to their symbols at runtime.
> > > It has a special method to resolve bitwise flag markers, such as
> > > those found in a TCP packet.
>
> > I've read this through three times and I still don't understand what
> > you're talking about.
>
> The constants pragma lets Perl turn names like PI and NEXT into values like
> '3.14' and '1' at compile time. It's a lot easier and more maintanable to
> use those names when programming. (Common sense.)
>
> At runtime, unless the author has gone to some trouble, there's no easy way
> of getting the name ('PI'), given the value ('3.14'). For some modules,
> that's no problem -- people who muck about inside should know what they're
> doing.
>
> With a module such as NetPacket::TCP, trying to see what flags are set on a
> packet doesn't work very well. The module defines constants corresponding to
> bits, using boolean logic to set and unset these bits with the flags. Using
> the module's published interface, attempting to read the flags returns a
> number like '24' instead of 'RST ACK SYN' or whatever.
>
> My solution is to overload constant::import, stashing away the names and
> values, so they can be fetched at runtime.
>
> Does that help?
> -- chromatic