File Coverage

blib/lib/PDLA/Exporter.pm
Criterion Covered Total %
statement 10 10 100.0
branch 7 8 87.5
condition 3 3 100.0
subroutine 2 2 100.0
pod n/a
total 22 23 95.6


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             PDLA::Exporter - PDLA export control
4              
5             =head1 DESCRIPTION
6              
7             Implements the standard conventions for
8             import of PDLA 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 PDLA::Exporter;
16              
17             use PDLA::MyModule; # Import default function list ':Func'
18             use PDLA::MyModule ''; # Import nothing (OO)
19             use PDLA::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 PDLA 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 PDLA module:
27              
28              
29             package PDLA::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 PDLA::Exporter;
39            
40             @ISA = qw(PDLA::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 PDLA::Exporter;
54              
55 77     77   498 use Exporter;
  77         137  
  77         12026  
56              
57             sub import {
58 2984     2984   81614 my $pkg = shift;
59 2984 100       21736 return if $pkg eq 'PDLA::Exporter'; # Module don't export thyself :)
60 2205         5070 my $callpkg = caller($Exporter::ExportLevel);
61 2205 50       7031 print "DBG: pkg=$pkg callpkg = $callpkg :@_\n" if($PDLA::Exporter::Verbose);
62 2205 100       6191 push @_, ':Func' unless @_;
63 2205 100 100     9180 @_=() if scalar(@_)==1 and $_[0] eq '';
64 2205         865473 Exporter::export($pkg, $callpkg, @_);
65             }
66              
67             1;
68              
69             =head1 SEE ALSO
70              
71             L
72              
73             =head1 AUTHOR
74              
75             Copyright (C) Karl Glazebrook (kgb@aaoepp.aao.gov.au).
76             Some docs by Christian Soeller.
77             All rights reserved. There is no warranty. You are allowed
78             to redistribute this software / documentation under certain
79             conditions. For details, see the file COPYING in the PDLA
80             distribution. If this file is separated from the PDLA distribution,
81             the copyright notice should be included in the file.
82              
83              
84             =cut