Skip to content

Instantly share code, notes, and snippets.

@earino
Created Feb 27, 2013
Embed
What would you like to do?
This is why 'use constant' is bad.
#!/usr/bin/env perl
#
use warnings;
use strict;
use Data::Dumper;
use constant MY_CONSTANT => 13;
my %foo = (MY_CONSTANT => 'dingle');
print Dumper \%foo;
#yields:
$VAR1 = {
'MY_CONSTANT' => 'dingle'
};
@clayne
Copy link

clayne commented Aug 15, 2016

Use +MY_CONSTANT or &MY_CONSTANT in the hash key portion. http://perldoc.perl.org/constant.html#CAVEATS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment