Devel::Constants

Devel::Constants is a Perl module that translates constants back to named symbols.
Download

Devel::Constants Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • chromatic
  • Publisher web site:
  • http://search.cpan.org/~chromatic/Crypt-CipherSaber-1.00/lib/Crypt/CipherSaber.pm

Devel::Constants Tags


Devel::Constants Description

Devel::Constants is a Perl module that translates constants back to named symbols. Devel::Constants is a Perl module that translates constants back to named symbols.SYNOPSIS # must precede use constant use Devel::Constants 'flag_to_names'; use constant A => 1; use constant B => 2; use constant C => 4; my $flag = A | B; print "Flag is: ", join(' and ', flag_to_names($flag) ), "n";Declaring constants is very convenient for writing programs, but as Perl often inlines them, retrieving their symbolic names can be tricky. This worse with lowlevel modules that use constants for bit-twiddling.Devel::Constants makes this much more manageable.It silently wraps around the constant module, intercepting all constant declarations. It builds a hash, associating the values to their names, from which you can retrieve their names as necessary.Note that you must use Devel::Constants before constant, or the magic will not work and you will be very disappointed. This is very important, and if you ignore this warning, the authors will feel free to laugh at you (at least a little.By default, Devel::Constants only intercept constant declarations within the same package that used the module. Also by default, it stores the constants for a package within a private (read, otherwise inaccessible) variable. You can override both of these.Passing the package flag to Devel::Constants with a valid package name will make the module intercept all constants subsequently declared within that package. For example, in the main package you might say: use Devel::Constants package => NetPacket::TCP; use NetPacket::TCP;All of the TCP flags declared within NetPacket::TCP are now available.It is also possible to pass in a hash reference in which to store the constant values and names: my %constant_map; use Devel::Constants %constant_map; use constant NAME => 1; use constant RANK => 2; use constant SERIAL => 4; print join(' ', values %constant_map), "n"; Requirements: · Perl


Devel::Constants Related Software