-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes_part_7.txt
67 lines (49 loc) · 2.25 KB
/
notes_part_7.txt
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---------- Notes on chapter 10 of Beginning Perl (Simon Cozens, 2000). ---------
Including other files:
do FILENAME;
Searches @INC for FILENAME and executes its contents as Perl script.
require FILENAME;
Same as "do", but only executes once for each file; will ignore subsequent
requires for the same file.
use FILENAME;
Same as "require". but executes before everything else in the program
no matter where the statement is placed.
To modify @INC:
Use the lib pragma:
use lib "my/module/directory";
use FILENAME;
----------------------------- PERL STANDARD MODULES ----------------------------
File::Find - Traverse directory trees, visit each file, and run a subroutine
(the callback) on them. There are 2 subroutines; find & finddepth.
Find does a depth-first preorder traversal. Finddepth does a
postorder traversal.
use File::Find;
find(\&wanted, @directories_to_search);
sub wanted { ... }
use File::Find;
finddepth(\&wanted, @directories_to_search);
sub wanted { ... }
Getopt::Std - Process single-character switches with switch clustering.
Getopt::Long - Same as previous, byt for multicharacter switches.
File::Spec - Module for handling, constructing, and splitting file names. It
offers the following functions:
canonpath ($path) cleans up $path to simplest form
catdir($dir1, $dir2) concatenates two directories
catfile($dir, $file) like catdir, but the path will end with a file name
tmpdir() finds a writeable directory for temp files
splitpath($path) splits path into volume, directories, and file name
splitdir($path) splits path into its constituent directories
path() returns search path for executable files
--------------------------------- CPAN MODULES ---------------------------------
Use the standard module called CPAN to enter the "CPAN Shell".
To enter, input:
perl -MCPAN -e shell
Which is the same as saying
#!/usr/bin/perl
use CPAN;
shell();
To install modules, use install command. For example:
install DBD::mysql
To get info on a module, use the i command:
i MLDBM
________________________________________________________________________________