随笔分类 - Perl
摘要:forfor(my $i=0;$i<10;$i++){ print $i;}foreachforeach my $col_id (sort {$a<=>$b;} keys %col_hash){ print $col_hash{$col_id};}while
阅读全文
摘要:示例程序:getopt.pl;#!/usr/bin/perl -w#use strict;use Getopt::Std;use vars qw($opt_a $opt_b $opt_c);getopts('a:b:c');print "opt_a =>;$opt_a\n" if $opt_a;print "opt_b =>;$opt_b\n" if $opt_b;print "opt_c =>;$opt_c\n" if $opt_c;注释:'a:b:c',a和b后有冒号,表示-a,-
阅读全文
摘要:perl调用perl文件可以使用两种方法:1.require "xxx.pl";2.use xxx.pm;加入require或者use在perl中相当于将文件xxx.pl/pm整个文件都添加到调用它的文件中;例如:gettime.pl#!/usr/bin/perlprint "gettime is 2011-07-25 14:40:10\n";showtime.pl#!/usr/bin/perlrequire "gettime.pl";print "get time ok\n";则执行showtime.pl会显示:
阅读全文
摘要:Perl中两种时间格式:print time(),"\n"; #取得系统时间print join(",",gmtime()),"\n"; #格林尼治时间print join(",",localtime()),"\n"; #本地时间131107659030,56,11,19,6,111,2,199,030,56,19,19,6,111,2,199,030秒,56分,19时,19日,7月,2011年,星期二,一年的第199天,夏令时无效令:($sec,$min,$hour,$day,$mon,$ye
阅读全文