Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Crazy constant question...

by johna (Monk)
on Dec 15, 2010 at 21:22 UTC ( [id://877380]=note: print w/replies, xml ) Need Help??


in reply to Crazy constant question...

This might work as well by inspecting the %constant::declared hash:
#!/usr/bin/perl use strict; use warnings; use constant { FOO => 1, BAR => 2, BAZ => 1 }; my %val_to_name; { no strict 'refs'; foreach my $con (keys(%constant::declared)) { push @{$val_to_name{$con->()}}, $con; } } my $thing = FOO; print "$thing defined by: " . join(" and ", @{$val_to_name{$thing}})." +\n";
Used a HoA to allow for multiple constants having the same value.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://877380]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-19 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found