lingyangxu的个人博客分享 http://blog.sciencenet.cn/u/lingyangxu

博文

Perl 文件基本统计

已有 2674 次阅读 2012-2-24 22:34 |系统分类:科研笔记|关键词:学者| Perl, 文件

use warnings;
use strict;
open FH,"test.txt";
open RESULT,">result.txt";
open LINE,">line.txt";
open LEN, ">length.txt";
while (<FH>)
{
 #chomp;
 print RESULT "line $. is  $_";
 print LINE "line $.\n";
 my $leng=length$_;
 print LEN "The length of line $. is $leng n";
}
close FH;
 
test.txt as follow 
1 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2
3 3 3 3 3 3 3 3 3


https://m.sciencenet.cn/blog-682293-541044.html

上一篇:Linux下升级R软件
下一篇:perl Getopt::Long

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-21 04:53

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部