File Coverage

blib/lib/PDL/Exporter.pm
Criterion Covered Total %
statement 16 16 100.0
branch 7 8 87.5
condition 3 3 100.0
subroutine 4 4 100.0
pod n/a
total 30 31 96.7


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             PDL::Exporter - PDL export control
4              
5             =head1 DESCRIPTION
6              
7             Implements the standard conventions for
8             import of PDL modules in to the namespace
9              
10             Hopefully will be extended to allow fine
11             control of which namespace is used.
12              
13             =head1 SYNOPSIS
14              
15             use PDL::Exporter;
16              
17             use PDL::MyModule; # Import default function list ':Func'
18             use PDL::MyModule ''; # Import nothing (OO)
19             use PDL::MyModule '...'; # Same behaviour as Exporter
20              
21             =head1 SUMMARY
22              
23             C is a drop-in replacement for the L
24             module. It confers the standard PDL export conventions to your module.
25             Usage is fairly straightforward and best illustrated by an example. The
26             following shows typical usage near the top of a simple PDL module:
27              
28              
29             package PDL::MyMod;
30              
31             use strict;
32            
33             # For Perl 5.6:
34             use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
35             # For more modern Perls:
36             our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
37            
38             require PDL::Exporter;
39            
40             @ISA = qw(PDL::Exporter);
41             @EXPORT_OK = qw(inc myfunc); # these will be exported by default
42             %EXPORT_TAGS = (Func=>[@EXPORT_OK],
43             Internal => [qw/internfunc1 internfunc2/],
44             );
45            
46             # ... body of your module
47            
48             1; # end of simple module
49              
50              
51             =cut
52              
53             package PDL::Exporter;
54 71     71   525 use strict;
  71         164  
  71         3001  
55 71     71   451 use warnings;
  71         256  
  71         4054  
56              
57 71     71   435 use Exporter;
  71         176  
  71         16904  
58              
59             sub import {
60 3298     3298   7913 my $pkg = shift;
61 3298 100       32831 return if $pkg eq 'PDL::Exporter'; # Module don't export thyself :)
62 2553         7321 my $callpkg = caller($Exporter::ExportLevel);
63 2553 50       13526 print "DBG: pkg=$pkg callpkg = $callpkg :@_\n" if($PDL::Exporter::Verbose);
64 2553 100       8160 push @_, ':Func' unless @_;
65 2553 100 100     13484 @_=() if scalar(@_)==1 and $_[0] eq '';
66 2553         1869225 Exporter::export($pkg, $callpkg, @_);
67             }
68              
69             1;
70              
71             =head1 SEE ALSO
72              
73             L
74              
75             =head1 AUTHOR
76              
77             Copyright (C) Karl Glazebrook (kgb@aaoepp.aao.gov.au).
78             Some docs by Christian Soeller.
79             All rights reserved. There is no warranty. You are allowed
80             to redistribute this software / documentation under certain
81             conditions. For details, see the file COPYING in the PDL
82             distribution. If this file is separated from the PDL distribution,
83             the copyright notice should be included in the file.
84              
85              
86             =cut