给 perl 增加 trim 函数
Tuesday, 5. February 2008, 08:04:58
#!/usr/bin/perl
sub trim($) {
($string) = $_[0];
$string =~ s/^\s*(.+)\s*$/$1/;
return $string;
}
#测试
print trim(" abcd ");
print "\n";
无不用其“极”
Tuesday, 5. February 2008, 08:04:58
#!/usr/bin/perl
sub trim($) {
($string) = $_[0];
$string =~ s/^\s*(.+)\s*$/$1/;
return $string;
}
#测试
print trim(" abcd ");
print "\n";
Wednesday, 9. January 2008, 07:39:52
Wednesday, 31. October 2007, 00:59:21
#!/usr/bin/perl ($u, $p)=@ARGV; @d=(A..Z,a..z); $s=$d[rand(52)].$d[rand(52)]; print $u.":".crypt($p, $s).":cvs\n";
Thursday, 16. August 2007, 08:26:10
Wednesday, 25. July 2007, 09:59:44
use strict;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => 'http://www.hoge.com/secret.html');
$req->authorization_basic('user', 'password');
my $res = $ua->request($req);
Monday, 25. June 2007, 04:33:43
#!/usr/bin/perl
system("stty -echo");
print "Enter your password: ";
chomp($passwd = <>);
print "\n(Test) Your password is $passwd\n";
system("stty echo");
Friday, 20. April 2007, 08:36:34
#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
my %ua_option = (
agent => "Mozilla/5.0",
timeout => 180,
);
my $ua = LWP::UserAgent->new(%ua_option);
my $url = 'http://your.domain.here/script_name.cgi'; # or 'https://...';
my %form;
$form{USER_ID} = 'user_id';
$form{PASSWORD} = 'password';
my $req = POST($url, [%form]);
my $res = $ua->request($req);
if ($res->is_success) {
print $res->header("Content-Type") . "\n";
print $res->status_line . "\n";
print $res->code . "\n";
print $res->header("Server") . "\n";
#print $res->header("Client-SSL-Cipher") . "\n";
#print $res->header("Client-SSL-Cert-Subject") . "\n";
#print $res->header("Client-SSL-Cert-Issuer") . "\n";
#print $res->header("If-SSL-Cert-Object") . "\n";
print $res->content;
} else {
print $res->status_line . "\n";
}
Friday, 6. April 2007, 02:06:32
#!/usr/local/bin/perl
use strict;
use vars qw($result_file);
$result_file = './ml_members.txt';
&main();
sub main()
{
if( -e $result_file ) {
unlink($result_file);
}
my $ezmlm_list = '/usr/local/bin/ezmlm/ezmlm-list';
my $ml_root = '/var/qmail/alias';
opendir(DIR, $ml_root) || die "Open dir $ml_root failed !";
my @all_ml = grep !/^\..*$/, readdir DIR;
my $user_id = '';
my $mail_addr = '';
my $list_cmd = '';
for my $ml_name (@all_ml) {
next if ($ml_name eq 'Mailbox' || $ml_name eq 'ezmlmadmtools' );
$list_cmd = "$ezmlm_list $ml_root/$ml_name";
system("echo $ml_name >> $result_file");
system("$list_cmd >> $result_file");
system("echo '' >> $result_file");
}
}
Wednesday, 4. April 2007, 02:31:19
#!/usr/bin/perl
$term = 10/(24*60); # 10 min
$file = '/tmp/testfile';
$age = (-M $file);
if($age > $term ) {
print "$file age: $age - old file\n";
} else {
print "$file age: $age - new file\n";
}
Friday, 9. March 2007, 06:54:25
Showing posts 1 - 10 of 17.
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
| ||||||
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | |||||
LinuxSir
Linux中坚站
为Linux工程师提供技术动力
打造中国最大的UNIX/LINIX资讯站
My mirror, my window, the bridge connecting you and I.
关注:php,mysql,ajax ,linux, js,开源
有用的Opera菜单
なにもあたらしくない
By Adam Li
By Satoru Watanabe
by singway
by 摸鱼儿
by Somh
by 法师
by yumumao
Maybe I was a Bird in another Life !
投放广告挣美元,可用PayPal接收付款
免费网页模板
数据表格样式收集