版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025版實習(xí)合同模板:實習(xí)期間實習(xí)成果轉(zhuǎn)化3篇
- 2025版木結(jié)構(gòu)景觀清包施工合同示范文本4篇
- 二零二五年度虛擬現(xiàn)實內(nèi)容創(chuàng)作者免責(zé)聲明合同范本4篇
- 2025版小型沼氣項目設(shè)備研發(fā)、生產(chǎn)、安裝及運營維護合同3篇
- 增值稅及其會計處理教學(xué)課件
- 2025版新能源汽車動力電池回收利用合同范本4篇
- 2025版小麥種子市場調(diào)研與風(fēng)險評估合同2篇
- 2025版學(xué)校臨時教師聘用合同實施細則3篇
- 二零二五版幕墻工程風(fēng)險管理與保險合同4篇
- 體育設(shè)施工程體育場地圍網(wǎng)施工考核試卷
- 定額〔2025〕1號文-關(guān)于發(fā)布2018版電力建設(shè)工程概預(yù)算定額2024年度價格水平調(diào)整的通知
- 2024年城市軌道交通設(shè)備維保及安全檢查合同3篇
- 【教案】+同一直線上二力的合成(教學(xué)設(shè)計)(人教版2024)八年級物理下冊
- 湖北省武漢市青山區(qū)2023-2024學(xué)年七年級上學(xué)期期末質(zhì)量檢測數(shù)學(xué)試卷(含解析)
- 單位往個人轉(zhuǎn)賬的合同(2篇)
- 科研倫理審查與違規(guī)處理考核試卷
- GB/T 44101-2024中國式摔跤課程學(xué)生運動能力測評規(guī)范
- 高危妊娠的評估和護理
- 2024年山東鐵投集團招聘筆試參考題庫含答案解析
- 兒童10歲生日-百日宴-滿月酒生日會成長相冊展示(共二篇)
- 2023年高考全國甲卷數(shù)學(xué)(理)試卷【含答案】
評論
0/150
提交評論