blob: ec15d71ccb85d47cbd9e5f26f59b12e26bcbae27 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
* Overview
This example package illustrates the implementation of dynamically
loaded Perl modules. The word dynamically here means that the module
name is not known beforehand to the main program. Instead, it is
supplied by the user via command line or configuration file.
For the clarity, this example implements a simple frontend program
"foobar" that takes as its argument a command name and a list of
arguments for that program. It looks for a Perl module for the
given command in the Perl path, loads the module and calls its 'run'
methods to perform the actual command.
* Package contents
foobar
Command line utility to illustrate command loading
lib/Example/Foobar.pm
Command loader.
lib/Example/Foobar/*.pm
Example loadable commands.
* Usage
To simplify test usage, the debug.sh script is provided that allows
you to try the package without installing. Run
. debug.sh
Then try
foobar list
This will show you the list of currently implemented commands. Run
any of them and inspect their sources.
Of course, the list command itself is also implemented as a loadable
module (lib/Example/Foobar/list.pm).
* Further reading
perldoc lib/Example/Foobar.pm et al.
Local Variables:
mode: outline
paragraph-separate: "[ ]*$"
version-control: never
End:
|