




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、Introduction to Perl & BioPerlDr G. P. S. Raghava Bioinformatics CentreIMTECH, ChandigarhEmail: raghavaimtech.res.inWeb: Perl IntroductionUsesShell scriptsCGI, web enginesGood atText processingSmall/Medium sized projectsQuick and dirty solutionsPortability (to a certain degree)PerlPractical Extracti
2、on and Report LanguageCreated by Larry WallRuns on just about every platformMost popular on Unix/Linux systemsExcellent language for file and data processingBasic ConceptsPerl files extension .PlCan create self executing scriptsAdvantage of PerlCan use system commandsComment entryPrint stuff on scre
3、enSimple Program#!/usr/local/bin/perl# This is a comment line. This program prints “Hello World.”# to the screen.print “Hello world.n”;On Unix, this is the location of the Perl interpreterComments start with # and end with the end of the lineProgram statements are terminated with semicolonsNewline c
4、haracterHow to Store ValuesScalar variablesList variablesPush,pop,shift,unshift,reverseHashes,keys,values,eachRead from terminal, command line argumentsRead and write to filesPerl Data TypesThree Main DatatypesScalarA single number, string or reference.$society = “Redbrick”;ListA collection of scala
5、r datatypes.societies = ( “RB”, “Drama”, “Film”);Length of an array with “scalar list”HashPairs of scalars, accessed by keys.%hash = ( “colour” = “red”,“make” = “corvette” ); Perl Basics ifSelective evaluate blocks of code depending on a condition.If ($string eq “blah”)print “String is blahn”;elsif
6、($string eq “spoo”)Print “String is spoon”;elsePrint “What the hell?n”;Perl Basics for Practically the same as C/C+/Javafor ($i = 0; $i 10; $i+)print “i is “ . $i . “n”;Perl Basics foreachA handy way of processing a listforeach $grocery (groceries)scan($grocery);Can use the default variable ($_)fore
7、ach (groceries)scan($_);Control Structures#!/usr/local/bin/perl# Print out 0,1,2,3,4,5,6,7,8,9# in this case, $x is local only to the loop because my is usedfor (my $x = 0; $x 10; $x+) print “$x”; if ($x 9) print “,”; print “n”;Control Structures#!/usr/local/bin/perl# Demonstrate the foreach loop, w
8、hich goes through elements# in an array.my users = (“bonzo”, “gorgon”, “pluto”, “sting”);foreach $user (users) print “$user is alright.n”;FunctionsUse sub to create a function.No named formal parameters, assign _ to local subroutine variables.#!/usr/local/bin/perl# Subroutine for calculating the max
9、imumsub max my $max = shift(_); # shift removes the first value from _ foreach $val (_) $max = $val if $max filename.txt” Truncate and write to file.“filename.txt” Append to file.Perl File I/O - ReadReading$string = ;list = ;while ($string = )print “LINE : “ . $string;Perl File I/O - WriteWriting to
10、 a file.print FILEHANDLE “Hello”;foreach $item (list)print FILEHANDLE $item;foreach (list)print FILEHANDLE;FilesFile handles are used to access filesopen and close functions#!/usr/local/bin/perl# Open a file and print its contents to copy.txtmy $filename = $ARGV0;open(MYFILE, “$filename”); # indicat
11、es writeopen(OUTPUT, “copy.txt”);while ($line = ) # The operator reads a line print OUTPUT $line; # no newline is needed, read from fileclose MYFILE; # Parenthesis are optionalPlatformsHP-UX / Itanium (ia64) 11.0 HP-UX / PA-RISC 11.0 MacOSMacOS XCygWin NT_5 v. 1.3.10 on Windows 2000 5.00 Win32, WinNT i386 IRIX64 6.5 SGI Solaris 2.8 UltraSparc OpenBSD 2.8 i386 RedHat Linux 7.2 i686 Linux i386 Perl CGI Example #!/usr/bin/perl w# My Third Perl script.# I call this scr
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- T/CSIQ 8013.1-2018一體化光伏箱變系列設備技術規范第1部分:總則
- T/CRIA 16007-2019TBM織物芯輸送帶
- T/CIS 17003-2019電子式互感器測試儀
- T/CIQA 16-2021方艙式核酸檢測實驗室通用技術規范
- T/CIMA 0079.1-2023基于電力流的碳排放計量第1部分:計量模型
- T/CIES 001-2016車庫LED照明技術規范
- T/CI 363-2024預制裝配式可拆底模高強吊鉤鋼筋桁架樓承板應用技術規程
- T/CESA 1325-2024會議場景智能拍攝系統技術要求
- T/CERDS 4-2022企業ESG報告編制指南
- T/CECS 10265-2023混凝土抗水滲透儀
- 2024版國開電大專科《現代教育思想》在線形考(形考任務一至二)+終結性考試試題
- 沉香項目市場營銷方案
- 辦公樓用電改造施工方案
- 安全風險四色分布圖圖例
- 物理才是最好的人生指南
- 來華留學生對中國文化認同感的探究
- 軟件系統操作手冊模板
- 物流專線合作協議書
- 華興報告生物育種:前沿生物技術改造下的新農業
- 四川玖誼源粒子科技有限公司回旋加速器生產及同位素應用研發基地環境影響報告表
- 樓頂發光字制作安裝合同
評論
0/150
提交評論