it works!
[p5sagit/Import-Into.git] / lib / Import / Into.pm
1 package Import::Into;
2
3 use strict;
4 use warnings FATAL => 'all';
5
6 our $VERSION = '1.0';
7
8 my %importers;
9
10 sub import::into {
11   my ($class, $target, @args) = @_;
12   $class->${\(
13     $importers{$target} ||= eval qq{
14       package $target;
15       sub { shift->import(\@_) };
16     } or die "Couldn't build importer for $target: $@"
17   )}(@args);
18 }
19
20 1;
21  
22 =head1 NAME
23
24 Import::Into - import packages into other packages 
25
26 =head1 SYNOPSIS
27
28   package My::MultiExporter;
29
30   use Thing1 ();
31   use Thing2 ();
32
33   sub import {
34     my $target = caller;
35     Thing1->import::into($target);
36     Thing2->import::into($target, qw(import arguments));
37   }
38
39 =head1 AUTHOR
40
41 mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>
42
43 =head1 COPYRIGHT
44
45 Copyright (c) 2010-2011 the Import::Into L</AUTHOR> and L</CONTRIBUTORS>
46 as listed above.
47
48 =head1 LICENSE
49
50 This library is free software and may be distributed under the same terms
51 as perl itself.