Perl: Practical Extraction & Reporting Language RL Schwartz, Learning Perl, RL Schwartz & L Wall, Programming Perl, O’Reilly & Associates
Perl complied programming language standard (procedural) programming language features + –regular expressions, system calls, file manipulation, report generation, data base manipulation, process management perfomance comparable to (or better than) Unix utilities and C
Standard Language Features sequence selection –if, if..else, if..elseif + unless, unless..else iteration –while, for(init; test; inc) + foreach var (list) functions (similar to C) data –scalar, array (list) + associative arrays - records
Associative Arrays keys –any scalar random access –set-like –unordered operations –keys(), values(), each(), delete()
Regular Expressions and Transliteration all the usual regular expressions =~ - true if matched, false otherwise change of delimiter split() - substrings join() - join substrings with given delimiter substitution translation
Text Files and Directories file and directory manipulation file handling (file handlers) –open() –close() –read and write line by line –check file status stat() lstat() - information on links binary files & data bases
Report Generation Perl formats - report writing templates fields –numbers, strings, lines, paragraphs headers page lengths
Process Management system(“command”) –launch a shell command `command` –launch a shell command fork and exec() –(almost) as in Unix (and C - see later) die –suicide sending signals –(almost) as in Unix eg kill(2, p1, p2) trapping signals