use warnings::register;
use vars qw($VERSION %declared);
-$VERSION = '1.17';
+$VERSION = '1.18';
#=======================================================================
my %forbidden = (%keywords, %forced_into_main);
+my $str_end = $] >= 5.006 ? "\\z" : "\\Z";
+my $normal_constant_name = qr/^_?[^\W_0-9]\w*$str_end/;
+my $tolerable = qr/^[A-Za-z_]\w*$str_end/;
+my $boolean = qr/^[01]?$str_end/;
+
#=======================================================================
# import() - import symbols into user's namespace
#
my $multiple = ref $_[0];
my $pkg = caller;
my $symtab;
- my $str_end = $] >= 5.006 ? "\\z" : "\\Z";
if ($] > 5.009002) {
no strict 'refs';
}
# Normal constant name
- if ($name =~ /^_?[^\W_0-9]\w*$str_end/ and !$forbidden{$name}) {
+ if ($name =~ $normal_constant_name and !$forbidden{$name}) {
# Everything is okay
# Name forced into main, but we're not in main. Fatal.
Carp::croak("Constant name '$name' begins with '__'");
# Maybe the name is tolerable
- } elsif ($name =~ /^[A-Za-z_]\w*$str_end/) {
+ } elsif ($name =~ $tolerable) {
# Then we'll warn only if you've asked for warnings
if (warnings::enabled()) {
if ($keywords{$name}) {
# Looks like a boolean
# use constant FRED == fred;
- } elsif ($name =~ /^[01]?$str_end/) {
+ } elsif ($name =~ $boolean) {
require Carp;
if (@_) {
Carp::croak("Constant name '$name' is invalid");