... xxxv
Part 1 Minimal Perl: for UNIX and Linux Users 1
1 Introducing Minimal Perl 3
1.1 A visit to Perlistan 3
Sometimes you need a professional guide 5
1.2 Perl can be simple 7
1.3 About Minimal Perl ... A Unix- like, OS-portable
find command 198
Making the most of find 2perl 198 ✦ Helping non -Unix
friends with
find 2perl 199
6.8 Summary 200
Directions for furthe...
... Minimal Perl 3
1. 1 A visit to Perlistan 3
Sometimes you need a professional guide 5
1. 2 Perl can be simple 7
1. 3 About Minimal Perl 7
What Minimal Perl isn’t 8 ✦ What Minimal Perl is 8
1. 4 Laziness ... Perlistan 3
1. 2 Perl can be simple 7
1. 3 About Minimal Perl 7
1. 4 Laziness is a virtue 9
1. 5 A minimal dose of syntax 10
1. 6 Writing one-line progra...
... routinely in Minimal Perl and removed only in the rare cases where it
spoils the results. It’s shown here for both the
sed and perl commands for uniformity.
WRITING SIMPLE SCRIPTS 37
The second form ... "msg"
format
validate_file2: Sorry, no switches allowed at validate_file2 line 6
Table 2. 6 Shell and Perl techniques for writing messages to STDOUT and STD...
... characters) that stands for something other than itself.
3
The word characters are defined later, in table 3. 5.
68 CHAPTER 3 PERL AS A (BETTER) grep COMMAND
The following command looks for matches ... delimiters
Matches perl in $_.
$data =~ /perl/ i Looks for a match
with perl in $data,
ignoring case
differences
Matches perl , PERL , Perl , and so
on in $data.
$data =~...
... was so easily incorporated into the Perl script.
For reference purposes, table 4. 6 provides a handy summary of the corresponding
sed and perl commands that perform basic editing tasks, along with ... more, Perl s Shell-inspired eval function can be used for much more than substitutions, as
you’ll see in section 8.7.
Ta b l e 4 . 6 sed and Perl commands for common editing...
... # Check for proper invocation
9 $amount and $rate or warn "$Usage\n" and exit 255 ;
10
11 $pct_rate=$rate/100; # 5 becomes . 05
12 $multiplier=1 + $pct_rate; # . 05 becomes 1. 05
13 # ... installing Perl (and therefore
find 2perl) , such people can use find
commands like those shown previously.
The procedure is as follows. The
find 2perl command is run with opti...
... similarities and differences in how data flows between com-
mands and functions.
7.3.1 Comparing Unix pipelines and Perl functions
Although there are distinct similarities between Unix command pipelines ... relatives in Unix
Built-in Perl
function
Unix relative(s) Purpose Effects
sort The Unix sort command List sorting Takes a list, and returns a
sorted list.
reverse...
...
ã
man perlop # operators, and command interpolation
ã
man perlsyn # basic syntax, including if/else
ã
man tput # command that retrieves terminal information
ã
man Term::ANSIColor # module for coloring ... treatment.
For help in spotting these syntax errors and others, try running your code through
a beautifier. You can learn about and download the standard Perl beautifier from
ht...
... }
NOTE The Shell’s for loop is similar to Perl s foreach loop, not Perl s
for loop.
10.5 LOOPING WITH for
Although the Shell’s for is like Perl s foreach, Perl does have a for loop of its own,
derived ... FACILITIES IN THE SHELL AND PERL 331
But adventurous Shell programmers will eventually encounter standard Unix
commands that don’t work this way. For example, both
tr...
... missing from Perl .
Table 10 .9 The Shell’s select loop
select var ; do commands; done # Form 0
select var in LIST; do commands; done # Form 1
Ta b l e 10 . 1 0 T h e
select loop for Perl
use Shell::POSIX::Select;
select ... conf commands specify your HOME directory’s myperl/lib (for library)
subdirectory as the storage location for the modules you install, and
HOME’s subdirec-...
... xxv
for loop 345–349
good for index-oriented array
processing 345
for loop (Perl)
syntax of 345
for loop (Shell) 331
compared to Perl s
foreach 340
foreach loop 340–344
compared to Shell’s for ... 189
See also command interpola-
tion
commands (AWK)
for printing rock-star
birthdays 130
Perl equivalents for simple
tasks 141
simple ones compared to Perl
equivalents 128
c...
... GlobalFree() and LocalFree(), actually perform virtu-
ally identical functions. Because of their greater flexibility we will use
GlobalAlloc() and GlobalFree() instead of new and delete or malloc and ... of formal
methods of specifications.
Therefore we settle for the lowest level of rigor, which we define as methodol
-
ogy for program development based on following a sequence of...
... of
10
and a
standard deviation of
0.5.
(a) Open a new workbook. In A1 of Sheet1 enter the label
data.
Use the command ToolslData Analysis and select the item
Random Number Generation. ... the standard deviation of the mean and s,is the standard
deviation
in
the
n
measurements.
To
calibrate a packing machine, an engineer has made a series of
measurements
of
th...
... value
1,
the formula
=d2ydx2(C2,62) returns the value -0.84147 098 178 296 2, The correct value is
cos
(l+n/2)
=
-0.84147 098 4807 897 (3.6
x
See
Also
dydx
O/O
error).
374
EXCEL: NUMERICAL ... On-Line
Help for information about the
relafiveTo
argument.
See also: Offset
And Operator
Logical operator.
(expressionl And expression2)
evaluates to
True
if both
expres...
...
Minimal Perl
Minimal Perl
For UNIX and Linux People
BY TIM MAHER
MANNING
Greenwich
(74° w. long.)
For online information and ordering of this and other Manning books, ... for all the good times we’ve had together.
vii
brief contents
Part 1 Minimal Perl: for UNIX and Linux Users 1
1 Introducing Minimal Perl 3
2 Perl essentials 16
3 Perl as a (better...