Professional Documents
Culture Documents
Full Chapter Advanced Perl Programming 1St Edition William Bo Rothwell Rothwell PDF
Full Chapter Advanced Perl Programming 1St Edition William Bo Rothwell Rothwell PDF
https://textbookfull.com/product/beginning-perl-programming-from-
novice-to-professional-william-bo-rothwell/
https://textbookfull.com/product/linux-for-developers-jumpstart-
your-linux-programming-skills-william-bo-rothwell/
https://textbookfull.com/product/adult-learning-basics-2nd-
edition-william-rothwell/
https://textbookfull.com/product/python-advanced-programming-the-
guide-to-learn-pyhton-programming-marcus-richards/
Practically Speaking 2nd Edition J. Dan Rothwell
https://textbookfull.com/product/practically-speaking-2nd-
edition-j-dan-rothwell/
https://textbookfull.com/product/think-perl-6-first-edition-
laurent-rosenfeld/
https://textbookfull.com/product/advanced-guide-to-
python-3-programming-hunt/
https://textbookfull.com/product/advanced-r-data-programming-and-
the-cloud-1st-edition-matt-wiley/
https://textbookfull.com/product/optimization-methods-in-
structural-design-1st-edition-alan-rothwell-auth/
William “Bo” Rothwell
The publisher, the authors and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.
1. Command-Line Options
William “Bo” Rothwell1
(1) El Cajon, CA, USA
Option Meaning
-- Terminates options
-0[octalnum] Specifies the input record separator as an octal character
-a Turns on autosplit if used with the -n or -p options
-c Checks syntax only
-d Executes Perl using the debugger
-Dnumber Sets debugging flags
-e ‘perl cmd’ Executes code listed on command line
-F/pattern/ Specifies what pattern to split on when -a is used
-h Displays a summary of command-line options
-i[ext] Tells Perl to edit files that are processed by <> in place
-Idir Specifies what directories to pre-append to the @INC array
Option Meaning
-l[octnum] Enables automatic line-end processing
-Mmodule Executes “use module” before running your script
-n Executes a while loop around your script
-p Executes a while loop around your script
-P Runs your script through the C preprocessor before compiling
-s Provides simple parsing of command-line options and arguments
-S Searches PATH variables to search for script
-T Turns on taint checks
-u Creates core dump file after compiling
-U Allows unsafe operations
-v Displays version of Perl
-V Displays configuration information of Perl
-w Prints warnings during executing about possible logical errors
-x [dir] Extracts scripts embedded in a message
Ted:9930:accounting:Bob:9940:HR:Sue:9950:accounting:
In this case, we could change the $/ variable to a colon (":") and
read the entire file into an array with each element being a field in the
array:
$/=":";
@fields=<STDIN>;
chomp (@fields);
$/="\n";
Notes:
The chomp command actually chomps whatever the $/ variable is set
to.
It’s important to set the $/ variable to its previous value as soon as
you are finished reading the file. This is because this is a truly global
variable and making changes to it could affect other portions of the
script.
With the -0 (zero) option, you can change the input record
separator on the command line. The value you specify has to be in octal
format. On a UNIX system, you can view octal numbers by looking at the
ASCII table:
#!perl
#sep.pl
#Note: assumes script was run with -0 option
Output of sep.pl:
while (<>) {
#Your code here
}
#!perl
#loop1.pl
In order for this to work, you will either need to execute Perl with
the -n option
#!perl -n
You can also use the -n option in conjunction with the -e option:
#!perl -p
#loop2.pl
tr/a-z/A-Z/;
#!perl -a -n
#auto1.pl
print "$F[0] \n";
Example output of auto1.pl:
Note Because of the way the magic cookie is parsed, these options
(-a and -F) may not perform correctly when used in the magic
cookie.
Editing in place
You can modify an existing file "in place " when you use the -i
option in conjunction with the -p option. The -i option tells Perl to
"print" back to the file instead of STDOUT.
Perl also allows you the option to automatically create a backup of
the original file. By adding an extension argument to the -i option, Perl
will modify the original file after making a backup of it.
The following example will capitalize the text in the file that is listed
as an argument on the command line and make a backup file called
"file.orig":
#!perl -p -i.orig
#edit1.pl
tr/a-z/A-Z/;
#!perl -p -iold.*
#edit2.pl
tr/a-z/A-Z/;
Physiologically after a meal is hyperæmic, and may increase one-third. Rich feed
and temporary idleness may cause morbid congestion. Other causes are:
ptomaines and toxins in spoiled food, hepatic irritants, damp, hot, tropical
climates, warm, damp, buildings, overfeeding, dilated right heart, insufficiency of
tricuspid valve, pulmonary emphysema or congestion. Absence of valve between
the right heart and hepatic veins, slow hepatic circulation, dilatability of hepatic
vascular system, compression of lung by false membranes, œdema, hepatization,
infarction, hydrothorax. In horse: special causes: spoiled fodders, carminatives,
volatile oils, work in hot sun, vaso-dilatation in heat and atony, falls, kicks, goring,
blows; passive forms from obstacles to the circulation. Lesions: Hepatic
enlargement to 20 or 30 pounds, and dark red color, darker spots of extravasation,
hepatic vein congestion in centre, and portal vein congestion in periphery of
acinus, softening, granular, fatty, nuclei disappear from hepatic cells, nutmeg liver,
cirrhosis. Symptoms: general febrile symptoms, great prostration, drowsiness,
slight colics, arched loins, trembling or jerking, lies on right side, percussion on
last ribs painful, slight icterus and increased urination and urea. In passive cases,
less icterus and kidney trouble; tends to intestinal catarrh and ascites. Prevention:
good hygiene, moderate laxative ration, cool air, exercise. Treatment: green or
laxative foods, salines, derivatives, water at will, always before morning feed. In
dog: overfeeding, indolence: pulmonary and circulatory troubles. Lesions: nutmeg
liver, degeneration, cirrhosis. Symptoms: pampered idleness, obesity, pulmonary
or cardiac disease, intestinal catarrh, piles, ascites, slight icterus, percussion
tenderness of right hypochondrium, lying on right side, increase of percussion
flatness. Treatment: saline purgatives or laxatives, antiseptics, restricted laxative
diet, open air exercise, derivatives, etc.