#!/usr/bin/perl use strict; use warnings; use constant ABC => 'abc'; use constant CDE => 'cde'; use Data::Dumper; # print the constants value before the sub below has been compiled # results in $VAR1 = 'abc' BEGIN { print Dumper( ABC ); print Dumper( CDE ); } # this is in a sub to show that it's not necessary # to actually call index to change the constants behaviour sub some1 { index( shift, ABC ) }; # prefixing the constant with an "&" prevents the error sub some2 { index( shift, &CDE ) }; # print the constants value after sub some has beenn compiled # results in $VAR1 = *bc; print Dumper( ABC ); print Dumper( CDE );