全部博文(22)
2013年(22)
分类: PERL
2013-05-24 11:42:37
获得打印句柄
例:例9.4
(From a Script)
1 while(){
2 print if /[A-Z][a-z]eve/;
}
_ _DATA_ _
Steve Blenheim 101
Betty Boop 201
Igor Chevsky 301
Norma Cord 401
Jonathan DeLoach 501
Karen Evich 601
(Output)
Steve Blenheim 101
打开文件句柄
例:
(The Text File: datebook)
Steve Blenheim
Betty Boop
Lori Gortz
Sir Lancelot
Norma Cord
Jon DeLoach
Karen Evich
--------------------------------------------------------------
(The Script)
#!/usr/bin/perl
# Open a file with a filehandle
1 open(FILE, "datebook") || die "Can't open datebook: $!\n";
2 while($line =
3 print "$line" if $line =~ /^Lori/;
4 }
5 close(FILE);
(Output)
3 Lori Gortz