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 78     78   523 use Exporter;
  78         189  
  78         12213  
56              
57             sub import {
58 3047     3047   82961 my $pkg = shift;
59 3047 100       22451 return if $pkg eq 'PDLA::Exporter'; # Module don't export thyself :)
60 2253         5462 my $callpkg = caller($Exporter::ExportLevel);
61 2253 50       7464 print "DBG: pkg=$pkg callpkg = $callpkg :@_\n" if($PDLA::Exporter::Verbose);
62 2253 100       6691 push @_, ':Func' unless @_;
63 2253 100 100     10081 @_=() if scalar(@_)==1 and $_[0] eq '';
64 2253         916387 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