Logic, Analysis, and Computation

宠辱不惊 静观窗前花开花落 去留无意 闲看天上云卷云舒

导航

<2009年6月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

统计

公告

如需转载, 请注明出处。

常用链接

留言簿

随笔分类

随笔档案

文章档案

I/O performance

搜索

最新评论

A simple perl script to extract digits from string

#! /usr/bin/perl -w


open FILE_INPUT, "<a.log" or die "Cannot open the file!" ;
open FILE_OUTPUT, ">res.txt" or die "Cannot open the file!";

$line = "";


while ($line = readline(FILE_INPUT)) {
    
$_ = $line;
    
if ( m/write: tcp:\/\/a/ ) {
        
@words = split(" ", $line);
        
foreach $w ( @words ) {
            
if ( $w=~ m/^\d/ ) {
                
print "$w\n";
            }
        }
        
    }

}

close FILE_INPUT;
close FILE_OUTPUT;

print "Done !\n";

posted on 2009-06-11 05:43 小学毕业生 阅读(248) 评论(0)  编辑 收藏 引用 所属分类: Programming


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理