File Coverage

blib/lib/PDLA/Exporter.pm
Criterion Covered Total %
statement 5 10 50.0
branch 1 8 12.5
condition 0 3 0.0
subroutine 2 2 100.0
pod n/a
total 8 23 34.7


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 117     117   620 use Exporter;
  117         202  
  117         23594  
56              
57             sub import {
58 117     117   356 my $pkg = shift;
59 117 50       4771 return if $pkg eq 'PDLA::Exporter'; # Module don't export thyself :)
60 0           my $callpkg = caller($Exporter::ExportLevel);
61 0 0         print "DBG: pkg=$pkg callpkg = $callpkg :@_\n" if($PDLA::Exporter::Verbose);
62 0 0         push @_, ':Func' unless @_;
63 0 0 0       @_=() if scalar(@_)==1 and $_[0] eq '';
64 0           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