PERL(1)PerlProgrammersReferenceGuidePERL(1)NNAAMMEEperl−PracticalExtractionandReportLanguageSSYYNNOOPPSSIISSppeerrll[−−ssTTuuUU][−−hhvv][−−VV[:configvar]][−−ccww][−−dd[:debugger]][−−DD[number/list]][−−ppnnaa][−−FFpattern][−−ll[octal]][−−00[octal]][−−IIdir][−−mm[−−]module][−−MM[−−]’module...’][−−PP][−−SS][−−xx[dir]][−−ii[extension]][−−ee’command’][----][programfile][argument]...Foreaseofaccess,thePerlmanualhasbeensplitupintoanumberofsections:perlPerloverview(thissection)perldeltaPerlchangessincepreviousversionperlfaqPerlfrequentlyaskedquestionsperltocPerldocumentationtableofcontentsperldataPerldatastructuresperlsynPerlsyntaxperlopPerloperatorsandprecedenceperlrePerlregularexpressionsperlrunPerlexecutionandoptionsperlfuncPerlbuiltinfunctionsperlvarPerlpredefinedvariablesperlsubPerlsubroutinesperlmodPerlmodules:howtheyworkperlmodlibPerlmodules:howtowriteanduseperlmodinstallPerlmodules:howtoinstallfromCPANperlformPerlformatsperllocalePerllocalesupportperlrefPerlreferencesperldscPerldatastructuresintroperllolPerldatastructures:listsoflistsperltootPerlOOtutorialperlobjPerlobjectsperltiePerlobjectshiddenbehindsimplevariablesperlbotPerlOOtricksandexamplesperlipcPerlinterprocesscommunicationperldebugPerldebuggingperldiagPerldiagnosticmessagesperlsecPerlsecurityperltrapPerltrapsfortheunwaryperlportPerlportabilityguideperlstylePerlstyleguideperlpodPerlplainolddocumentationperlbookPerlbookinformation22/Jul/98perl5.005,patch021PERL(1)PerlProgrammersReferenceGuidePERL(1)perlembedPerlwaystoembedperlinyourCorC++applicationperlapioPerlinternalIOabstractioninterfaceperlxsPerlXSapplicationprogramminginterfaceperlxstutPerlXStutorialperlgutsPerlinternalfunctionsforthosedoingextensionsperlcallPerlcallingconventionsfromCperlhistPerlhistoryrecords(Ifyou’reintendingtoreadthesestraightthroughforthefirsttime,thesuggestedorderwilltendtoreducethenumberofforwardreferences.)Bydefault,alloftheabovemanpagesareinstalledinthe/usr/local/man/directory.ExtensiveadditionaldocumentationforPerlmodulesisavailable.Thedefaultconfigurationforperlwillplacethisadditionaldocumentationinthe/usr/local/lib/perl5/mandirectory(orelseinthemansubdirec-toryofthePerllibrarydirectory).SomeofthisadditionaldocumentationisdistributedstandardwithPerl,butyou’llalsofinddocumentationforthird-partymodulesthere.YoushouldbeabletoviewPerl’sdocumentationwithyourman(1)programbyincludingtheproperdirec-toriesintheappropriatestart-upfiles,orintheMANPATHenvironmentvariable.Tofindoutwheretheconfigurationhasinstalledthemanpages,type:perl-V:man.dirIfthedirectorieshaveacommonstem,suchas/usr/local/man/man1and/usr/local/man/man3,youneedonlytoaddthatstem(/usr/local/man)toyourman(1)configurationfilesoryourMANPATHenvironmentvariable.Iftheydonotshareastem,you’llhavetoaddbothstems.Ifthatdoesn’tworkforsomereason,youcanstillusethesuppliedperldocscripttoviewmoduleinforma-tion.Youmightalsolookintogettingareplacementmanprogram.Ifsomethingstrangehasgonewrongwithyourprogramandyou’renotsurewhereyoushouldlookforhelp,trythe−−wwswitchfirst.Itwilloftenpointoutexactlywherethetroubleis.DDEESSCCRRIIPPTTIIOONNPerlisalanguageoptimizedforscanningarbitrarytextfiles,extractinginformationfromthosetextfiles,andprintingreportsbasedonthatinformation.It’salsoagoodlanguageformanysystemmanagementtasks.Thelanguageisintendedtobepractical(easytouse,efficient,complete)ratherthanbeautiful(tiny,elegant,minimal).Perlcombines(intheauthor’sopinion,anyway)someofthebestfeaturesofC,sseedd,aawwkk,andsshh,sopeoplefamiliarwiththoselanguagesshouldhavelittledifficultywithit.(Languagehistorianswillalsonotesomevestigesofccsshh,Pascal,andevenBASIC−PLUS.)ExpressionsyntaxcorrespondsquitecloselytoCexpres-sionsyntax.UnlikemostUnixutilities,Perldoesnotarbitrarilylimitthesizeofyourdata—ifyou’vegotthememory,Perlcanslurpinyourwholefileasasinglestring.Recursionisofunlimiteddepth.Andthetablesusedbyhashes(previouslycalled‘‘associativearrays)growasnecessarytopreventdegradedper-formance.Perlusessophisticatedpatternmatchingtechniquestoscanlargeamountsofdataveryquickly.Althoughoptimizedforscanningtext,Perlcanalsodealwithbinarydata,andcanmakedbmfileslooklikehashes.SetuidPerlscriptsaresaferthanCprogramsthroughadataflowtracingmechanismwhichpreventsmanystupidsecurityholes.Ifyouhaveaproblemthatwouldordinarilyusesseeddoraawwkkorsshh,butitexceedstheircapabilitiesormustrunalittlefaster,andyoudon’twanttowritethesillythinginC,thenPerlmaybeforyou.TherearealsotranslatorstoturnyoursseeddandaawwkkscriptsintoPerlscripts.Butwait,there’smore...Perlversion5isnearlyacompleterewrite,andprovidesthefollowingadditionalbenefits:2perl5.005,patch0222/Jul/98PERL(1)PerlProgrammersReferenceGuidePERL(1)•ManyusabilityenhancementsItisnowpossibletowritemuchmorereadablePerlcode(evenwithinregularexpressions).For-merlycrypticvariablenamescanbereplacedbymnemonicidentifiers.Errormessagesaremoreinformative,andtheoptionalwarningswillcatchmanyofthemistakesanovicemightmake.Thiscannotbestressedenough.Wheneveryougetmysteriousbehavior,trythe−−wwswitch!!!Wheneveryoudon’tgetmysteriousbehavior,tryusing−−wwanyway.•Simpl