home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl_mlb.zip / subs.pm < prev    next >
Text File  |  1997-11-25  |  815b  |  39 lines

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