Skip to content

Instantly share code, notes, and snippets.

@earino
Created February 27, 2013 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save earino/5051998 to your computer and use it in GitHub Desktop.
Save earino/5051998 to your computer and use it in GitHub Desktop.
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