]> perl5.git.perl.org Git - perl5.git/blob - lib/subs.pm This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Deparse: exclude two new test files
[perl5.git] / lib / subs.pm
1 package subs;
2
3 use strict;
4 use warnings;
5
6 our $VERSION = '1.04';
7
8 =head1 NAME
9
10 subs - 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
19 This will predeclare all the subroutines whose names are
20 in the list, allowing you to use them without parentheses (as list operators)
21 even before they're declared.
22
23 Unlike pragmas that affect the C<$^H> hints variable, the C<use vars> and
24 C<use subs> declarations are not lexically scoped to the block they appear
25 in: they affect
26 the entire package in which they appear.  It is not possible to rescind these
27 declarations with C<no vars> or C<no subs>.
28
29 See L<perlmodlib/Pragmatic Modules> and L<strict/strict subs>.
30
31 =cut
32
33 sub 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
43 1;