use
warnings
qw(FATAL all NONFATAL misc)
;
sub
wrap {
my
(
$re
,
$partial
) =
@_
;
$partial
?
$re
:
qq!^$re\\z!
;
}
sub
re_name { wrap(
qr{\w+}
,
$_
[1]) }
sub
re_digit { wrap(
qr{(?:[0-9]+)}
,
$_
[1]) }
sub
re_integer { wrap(
qr{(?:0|[1-9]\d*)}
,
$_
[1]) }
sub
re_any { wrap(
qr{.*}
s,
$_
[1]) }
sub
re_nonempty {
qr{\S.*}
s }
*re_word
=
*re_name
;
*re_word
=
*re_name
;
*re_int
=
*re_integer
;
*re_int
=
*re_integer
;
*re_digits
=
*re_digit
;
*re_digits
=
*re_digit
;
__PACKAGE__->build_exports(\
our
(
@EXPORT
,
@EXPORT_OK
));
sub
build_exports {
my
(
$pack
,
@vars
) =
@_
;
my
$symtab
= symtab(
$pack
);
foreach
my
$name
(
grep
{/^re_/}
keys
%$symtab
) {
my
$glob
=
$symtab
->{
$name
};
next
unless
*{
$glob
}{CODE};
push
@$_
,
$name
for
@vars
;
}
}
1;