perl使用介绍

perl使用介绍

ID:22100486

大小:170.50 KB

页数:83页

时间:2018-10-27

perl使用介绍_第1页
perl使用介绍_第2页
perl使用介绍_第3页
perl使用介绍_第4页
perl使用介绍_第5页
资源描述:

《perl使用介绍》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、Perl使用介紹What’sPerlWhatisPerl?PracticalExtractionPerlLanguagePathologicallyElectricRubbishListerPracticallyEverythingReallyLikeableshells,awk,sed,grep,CWhat’sPerlfor?Manipulatetextinfiles,extractdatafromfileswritereportsMultiplePlatformPerlScriptsPerlattheCommandLineScriptSetupTheScri

2、ptPerlattheCommandLineWhereisPerl?/usr/local/binThe‘-e’switch:由CommandLine執行Perl$perl-e‘print“hellodolly”’;The‘-n’Switch:對檔案的每一行執行相同的動作Example1The‘-c’Switch:檢查Script的語法$perl-ce‘printif/Igor’emp.first$perl-ce‘printif/Igor/’emp.firstScriptSetupStatementsareterminatedwithasemicolon(;)

3、只有子程式(subroutine)與報告(reportformat)需要先宣告Variable不需先宣告Initialize為0或空字串(‘’)TheScriptStartup:Script的第一行寫上#!#!/usr/local/bin/perlComments:#SampleScript:ex2.perl如果第一行沒加上#!?perlPrintingFileHandleWordsTheprintFunctionTheprintfFunctionFileHandleThethreepredefinedfilehandle

4、s::StandardInput:StandardOutput:StandardErrorTheprintandprintffunctionssendtheiroutputbydefaulttotheSTDOUTfilehandleWords大小寫不同(casesensitive)Quotes單引號:不做任何變數或特殊字元的轉換雙引號$,$,@,%常數(Literal,Constant)數值常數123450x456fff(16進位)0777(8進位)23.45.234E-2字串常數t

5、rfbae33xffluLUE\常數(Cont.)特殊常數_LINE_:CurrentLineNumber_FILE_:CurrentFileName_END_:Logicalendofthescript;trailinggarbageisignoredTheprintFunctionExample3PrintingLiterals:Example4,5TheprintfFunctionThesameasinCFormatSpecifiers(Example6)c:Characters:Stringd:Decimal;ld:LongDe

6、cimalu:UnsignedDecimal;lu:LongUnsignedDecimalx:Hex;lx:LongHexo:Octal;lo:LongOctale:ScientificNotationf:FloatingPointg:eorf(whichtakestheleastspace)What’sinaName?AboutPerlvariablesScalars,Arrays,andAssociativeArraysReadingfromSTDINArrayFunctionsAssociativeArrayFunctionsAboutPerlVariab

7、lesTypesscalar,array,andassociativearrayScopeandPackageDefaultglobalinscopeNamingConventions$var-->Scalarvariable@var-->Arrayvariable%var-->AssociativevariableCasesensitive初始值為0或空字串AboutPerlVariables(Cont.)Example7QuotingRules(Example8)“…”scalarvariable與array會換成該有的值Associativearray不會

8、換t,,…等一定要

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。