1package subs; 2 3use strict; 4use warnings; 5 6our $VERSION = '1.04'; 7 8=head1 NAME 9 10subs - Perl pragma to predeclare subroutine names 11 12=head1 SYNOPSIS 13 14 use subs qw(frob); 15 frob 3..10; 16 17=head1 DESCRIPTION 18 19This will predeclare all the subroutines whose names are 20in the list, allowing you to use them without parentheses (as list operators) 21even before they're declared. 22 23Unlike pragmas that affect the C<$^H> hints variable, the C<use vars> and 24C<use subs> declarations are not lexically scoped to the block they appear 25in: they affect 26the entire package in which they appear. It is not possible to rescind these 27declarations with C<no vars> or C<no subs>. 28 29See L<perlmodlib/Pragmatic Modules> and L<strict/strict subs>. 30 31=cut 32 33sub import { 34 my $callpack = caller; 35 my $pack = shift; 36 my @imports = @_; 37 foreach my $sym (@imports) { 38 no strict 'refs'; 39 *{"${callpack}::$sym"} = \&{"${callpack}::$sym"}; 40 } 41}; 42 431; 44