版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、OutlineIntroduction.Installation.Background knowledge in Perl.Data type.Control structure.Regular expression.Overall practice.IntroductionPerl is free software.Larry Wall (He is a linguist).The history of Perl language.1987- Perl 1.0.1994 - Perl 5 (contain OOP).OOP (object oriented programming) 物件導向
2、程式語言2003 Perl 6.Now.Characteristic.The script language base on C language (具跨平台的特性).Installation Perl is the default language in any distribution of Linux.Perl can be executed and worked by the ActivePerl package in windows platform. How to edit Perl program?Notepad in windows, UltraEdit and any tex
3、t editor.Installation cont.Practice.Download ActivePerl software file.Install ActivePerl.Background knowledgeData type in Perl.Control structure in Perl.Regular expression in Perl.Data type in PerlLike EnglishScalar (純量變數) 比喻單件事物.數字常數 $x = 5;字串常數 $y = “Hello” ;The special expression of Perl.Print “H
4、ello” . ”World” ; (Hello World).Print “Hello” * 2 ; (HelloHello).字串與數字間的轉換$x = 123; $y = “456”;Print $x + $y ; (數字)Print $x . $y ; (字串)Data type in Perl cont.Practice.Using scalar.Special expression.字串與數字間的轉換.Data type in Perl cont.Array (陣列).The definition of Array in Perl.student=(9154610,9154611,
5、”9154612”);my student;$student0 =9154610“; $student1 =“9154611“; $student2 =“9154611”; Array 單數的取用.print $student0,n;print $student1n; print $student2.n; Array 複數的取用.print student,“n”; (全部一起print出來)以單數取用方式print出複數資料 (in control structure chapter).Data type in Perl cont.Practice.Using array (definiti
6、on).單數取用.複數取用.Data type in Perl cont.Hash (雜湊).$純量 = 單一 = 單數陣列 = 串列 = 複數%雜湊 = 串列 = 複數定義陣列 = 類似ipstudent=(9154610,9154611,”9154612”);定義雜湊 = 類似dns%students = (Peter=9154610 , Mary=9154611 , Cathy=9154612);Data type in Perl cont.Hash (雜湊).定義雜湊 = 類似dns%students = (Peter=9154610 , Mary=9154611 , Cathy=91
7、54612);Hash 單數的取用.print $studentsPeter,n;print $studentsMary,n; print $studentsCathy,n;Hash 複數的取用.print %students,n;以單數取用方式print出複數資料 (in control structure chapter).Data type in Perl cont.Practice.Using hash (definition).單數取用.複數取用.Control structure in PerlIf statement (陳述式).For loop (迴圏).Foreach loo
8、p (迴圏).While loop (迴圏).Control structure in Perl cont.If If 條件判斷條件判斷If If 條件成立則執行條件成立則執行若若If If 條件不成立則執行條件不成立則執行 (else statement(else statement可有可無可有可無) )If statement (陳述式).Control structure in Perl cont.Practice.If statement.If - else statement.Control structure in Perl cont.For loop (迴圏).$#array :
9、 $#array : 取得取得arrayarray的大小的大小$i+ : $i+ : 等同於等同於 $i = $i + 1; $i = $i + 1;$sum += $i : $sum += $i : 等同於等同於 $sum = $sum + $i; $sum = $sum + $i;Control structure in Perl cont.Practice.For loop 迴圏.以array單數取用方式print出array複數資料.以hash單數取用方式print出hash複數資料.Control structure in Perl cont.Foreach loop (迴圏).Li
10、ke for loop.For loopFor loopForeach loopForeach loopControl structure in Perl cont.Practice.Foreach loop (迴圏).以array單數取用方式print出array複數資料.以hash單數取用方式print出hash複數資料.Control structure in Perl cont.While loop (迴圏).While While 判斷式判斷式Control structure in Perl cont.Practice.While loop (迴圏).1+2+100.Regular expression in Perl樣式 (pattern) 的表達.繫結符號 =.=可用來將右邊的樣式比對左邊的字串純量,成功傳回1,失敗傳回0.表否定則可改用!通常搭配判斷式使用.Regular expression in Perl cont.比對.$ : 代表字串中比對成功之前的部分.$& : 代表字串中比對成功的部分.$ : 代表字串中比對成功之後的部分.Regular expression in Perl cont.字元取代.$var = tr/xxx/yyy/把變數 $var 內的 xxx 字元都逐一代
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年杭州科技职业技术学院单招职业倾向性测试模拟测试卷附答案
- 2026年江西建院单招试题附答案
- 2026年伊春职业学院单招综合素质笔试模拟试题带答案解析
- 2026年重庆市江津区社区专职人员招聘(642人)笔试备考试题及答案解析
- 2026年心理知识大赛试题及答案1套
- 2026年心理学知识试题及一套答案
- 2026年物业电工试题含答案
- 中国烟草总公司青州中等专业学校2026年高校毕业生招聘4人(山东)笔试备考题库及答案解析
- 广安市武胜超前外国语学校招聘笔试备考试题及答案解析
- 2026广西南宁市兴宁区五塘镇中心学校春季学期顶岗教师招聘笔试备考题库及答案解析
- 小学音乐教师年度述职报告范本
- 国家开放大学电大本科《流通概论》复习题库
- 机关档案汇编制度
- 2025年下半年四川成都温江兴蓉西城市运营集团有限公司第二次招聘人力资源部副部长等岗位5人参考考试题库及答案解析
- 2026福建厦门市校园招聘中小学幼儿园中职学校教师346人笔试参考题库及答案解析
- 2025年高职物流管理(物流仓储管理实务)试题及答案
- 设备管理体系要求2023
- 2025年学法减分试题及答案
- 2025年特种作业人员考试题库及答案
- GB/T 1048-2019管道元件公称压力的定义和选用
- 文化创意产品设计及案例PPT完整全套教学课件
评论
0/150
提交评论