1 / 47
文档名称:

Perl Turorial Perl 笔记.ppt

格式:ppt   页数:47页
下载后只包含 1 个 PPT 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

Perl Turorial Perl 笔记.ppt

上传人:tmm958758 2015/5/27 文件大小:0 KB

下载得到文件列表

Perl Turorial Perl 笔记.ppt

相关文档

文档介绍

文档介绍:1
Perl Tutorial
HY439
Autumn 2005
2
Why Perl?
Perl is built around regular expressions
REs are good for string processing
Therefore Perl is a good scripting language
Perl is especially popular for CGI scripts
Perl makes full use of the power of UNIX
Short Perl programs can be very short
“Perl is designed to make the easy jobs easy, without making the difficult jobs impossible.”-- Larry Wall, Programming Perl
HY439
Autumn 2005
3
Why not Perl?
Perl is very UNIX-oriented
Perl is available on other platforms...
...but isn’t always fully implemented there
However, Perl is often the best way to get some UNIX capabilities on less capable platforms
Perl does not scale well to large programs
Weak subroutines, heavy use of global variables
Perl’s syntax is not particularly appealing
HY439
Autumn 2005
4
What is a scripting language?
Operating systems can do many things
copy, move, create, delete, compare files
execute programs, pilers
schedule activities, monitor processes, etc.
mand-line interface gives you access to these functions, but only one at a time
A scripting language is a “wrapper” language that integrates OS functions
HY439
Autumn 2005
5
Major scripting languages
UNIX has sh, Perl
Macintosh has AppleScript, Frontier
Windows has no major scripting languages
probably due to the weaknesses of DOS
Generic scripting languages include:
Perl (most popular)
Tcl (easiest for beginners)
Python (new, Java-like, best for large programs)
HY439
Autumn 2005
6
Perl Example 1
#!/usr/local/bin/perl
#
# Program to do the obvious
#
print 'Hello world.'; # Print a message
HY439
Autumn 2005
7
Comments on “Hello, World”
Comments are # to end of line
But the first line, #!/usr/local/bin/perl, tells where to find the piler on your system
Perl statements end with semicolons
Perl is case-sensitive
Perl piled and run in a single operation
HY439
Autumn 2005
8
Perl Example 2
#!/ex2/usr/bin/perl
# Remove blank lines from a file
# Usage: singlespace < oldfile > newfil