1Package::Generator(3) User Contributed Perl DocumentationPackage::Generator(3)
2
3
4
6 Package::Generator - generate new packages quickly and easily
7
9 version 0.100
10
11 $Id: /my/cs/projects/pkg-gen/trunk/lib/Package/Generator.pm 22111 2006-06-05T18:39:59.581255Z rjbs $
12
14 use Package::Generator;
15
16 my $package = Package::Generator->new_package;
17 ...
18
20 This module lets you quickly and easily construct new packages. It
21 gives them unused names and sets up their package data, if provided.
22
24 new_package
25
26 my $package = Package::Generator->new_package(\%arg);
27
28 This returns the newly generated package. It can be called with no
29 arguments, in which case it just returns the name of a pristene pack‐
30 age. The "base" argument can be provided to generate the package under
31 an existing namespace. A "make_unique" argument can also be provided;
32 it must be a coderef which will be passed the base package name and
33 returns a unique package name under the base name.
34
35 A "data" argument may be passed as a reference to an array of pairs.
36 These pairs will be used to set up the data in the generated package.
37 For example, the following call will create a package with a $foo set
38 to 1 and a @foo set to the first ten counting numbers.
39
40 my $package = Package::Generator->new_package({
41 data => [
42 foo => 1,
43 foo => [ 1 .. 10 ],
44 ]
45 });
46
47 For convenience, "isa" and "version" arguments may be passed to
48 "new_package". They will set up @ISA, $VERSION, or &VERSION, as appro‐
49 priate. If a single scalar value is passed as the "isa" argument, it
50 will be used as the only value to assign to @ISA. (That is, it will
51 not cause $ISA to be assigned; that wouldn't be very helpful.)
52
53 assign_symbols
54
55 Package::Generator->assign_symbols($package, \@key_value_pairs);
56
57 This routine is used by ""new_package"" to set up the data in a pack‐
58 age.
59
60 package_exists
61
62 ... if Package::Generator->package_exists($package);
63
64 This method returns true if something has already created a symbol ta‐
65 ble for the named package. This is equivalent to:
66
67 ... if defined *{$package . '::'};
68
69 It's just a little less voodoo-y.
70
72 Ricardo SIGNES, "<rjbs@cpan.org>"
73
75 Please report any bugs or feature requests to "bug-package-genera‐
76 tor@rt.cpan.org", or through the web interface at <http://rt.cpan.org>.
77 I will be notified, and then you'll automatically be notified of
78 progress on your bug as I make changes.
79
81 Copyright 2006 Ricardo Signes, all rights reserved.
82
83 This program is free software; you can redistribute it and/or modify it
84 under the same terms as Perl itself.
85
86
87
88perl v5.8.8 2006-06-05 Package::Generator(3)