Perl 4 sa

741 views
646 views

Published on

新人perl培训

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
741
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Perl 4 sa

  1. 1. Perl<br />
  2. 2. 提纲<br />读写文件<br />变量<br />逻辑控制<br />胶水<br />
  3. 3. Perl的好处<br />生产效率高<br />
  4. 4. 开始!Perlit!<br />1、创建一个it.pl文件<br />2、perl it.pl<br />perl –e “print ‘hello,world’”<br />
  5. 5. Perl的奇妙变量<br />$_<br />@_<br />
  6. 6. 读写文件<br />
  7. 7. Perl 读文件<br />open $fh,’<’,’/etc/passwd’;<br />while(<$fh>){print $_;}<br />
  8. 8. Perl写文件<br />open$fh,”>”,”123.txt”;<br />print $fh “write it down.”;<br />
  9. 9. 变量<br />
  10. 10. 标量$<br />数组@<br />哈希%<br />
  11. 11. 标量 scalar<br />my $string = ‘曾文杰’;<br />my $number = 5143;<br />
  12. 12. 数组 array<br />my @person = (‘曾文杰’,’唐骏’,’张阳’);<br />my @code = (5143,250,5145);<br />
  13. 13. 哈希 hash<br />%person = ( <br />“5143” => “曾文杰",<br />“250” => “唐骏",<br />“5145” => “张阳", <br />);<br />
  14. 14. 逻辑控制<br />
  15. 15. if<br />if ($name eq “张阳") <br />{ print “welcome"; }<br />else<br />{ print “get out”;}<br />if ($age == 60)<br />{ print “oldman"; }<br />
  16. 16. while<br />while($foo < 100)<br />{ print $foo++;}<br />
  17. 17. for<br />for($i=1;$i<100;$i++)<br />{print $_;}<br />for(1..99)<br />{print $_;}<br />
  18. 18. foreach<br />foreach my $person (‘超人’, ’钢铁侠’, ’闪电侠’)<br />{print $person;}<br />
  19. 19. 更多控制<br />google<br />循序渐进、按需索求<br />
  20. 20. 胶水语言<br />
  21. 21. DBI<br />
  22. 22. system(“ls”);<br />`ls`;<br />
  23. 23. 替代awk和sed<br />
  24. 24. sed<br />perl -pi -e 's/aaa/bbb/' filename<br />
  25. 25. awk<br />perl -lane 'print $F[0] + $F[-2]'<br />
  26. 26. 更多内容<br />子函数、模块<br />OOP<br />正则表达式<br />程序打包<br />CPAN<br />
  27. 27. 进一步学习<br />perldoc<br />《Perl语言入门》<br />
  28. 28. 拜谁所赐?<br />LarryWall<br />CPANAuthors<br />

×