shell按列求和
http://www.linuxsong.org/2008/08/shell_05.html[@more@]Shell中如何按列求和? 转载http://www.linuxsong.org/2008/08/shell_05.html在Shell中,我们可以用awk实现按列求和的功能,非常简单。看下面的例子:1.简单的按列求和[linux@test /tmp]$ cat test123.52125.54126.36[linux@test /tmp]$ awk '{sum += $1};END {print sum}' test375.422.对符合某些条件的行,按列求和[linux@test /tmp]$ cat testaaa 123.52bbb 125.54aaa 123.52aaa 123.52ccc 126.36对文件test中 第一列为aaa的行求和[linux@test /tmp]$ awk '/aaa/ {sum += $2};E
DBI@参数数据类型
DBI@[@more@]简单记录下先http://search.cpan.org/~timb/DBI/DBI.pm#DBI_Constantshttp://perl.enstimac.fr/perl5.6.1/site_perl/5.6.1/sun4-solaris/DBD/Oracle.html#item_ora_type foreach (@{ $DBI::EXPORT_TAGS{sql_types} }) { printf "%s=%dn", $_, &{"DBI::$_"}; }
通过hostname获取IP的perl脚本
作者: 弦乐之花 | 可以转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明链接http://shiri512003.itpub.net/post/37713/499431[@more@]有时候我们会需要获取主机IP信息,下面收录一个通过主机名获取IP的perl脚本http://www.metalshell.com/source_code/36/Hostname_Lookup.html#!/usr/bin/perl # resolv.pl written by detour@metalshell.com # # Resolves an ip into a host or a host into an ip. # # http://www.metalshell.com/ # use Socket; use strict; my $host_name = hostname($ARGV[0]); print &
perl中文处理问题
作者: 弦乐之花 | 可以转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明链接:http://shiri512003.itpub.net/post/37713/497263[@more@]$dbh->do("SET character_set_client = 'gbk'");$dbh->do("SET character_set_connection = 'gbk'");如果需要显示结果,加上$dbh->do("SET character_set_results= 'gbk' ");
文件操作之flock
flock[@more@]flock FILEHANDLE,OPERATION Calls flock(2), or an emulation of it, on FILEHANDLE. Returns true for success, false on failure. Produces a fatal error if used on a machine that doesn't implement flock(2), fcntl(2) locking, or lockf(3). flock is Perl's portable file locking interface, although it locks only entire files, not records.Two potentially non-obvious but traditional flock semantics are that it waits indefinitely until the lock is granted, and that its locks merely advisory. Su