You can place the constant within parens, causing it to be checked at compiletime.
use strict; use warnings; use Data::Dumper; use constant THIS => 100; print "Testing: \n"; my %hash = ( (THIS) => 200 ); print Dumper \%hash;
Try that code with the "use constant" line commented out, and you'll see it generates a compiletime error. The error you'll get is something along the lines of:
Bareword "THIS" not allowed while "strict subs" in use at mytest.pl line 12. Execution of mytest.pl aborted due to compilation errors.
Dave
In reply to Re: Constants and arrow notation.
by davido
in thread Constants and arrow notation.
by dmitri
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |