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