ITeye博客

perl读写文件

luogen33 · 2012-05-23 10:03 · 编程语言 · Markdown

#!/usr/bin/perl my $SRC_FILE="/home/lgg/t.txt"; my $DEST_FILE="/home/lgg/dest.txt"; if (open (SRCFILE ,"<$SRC_FILE")) { open (DESTFILE ,">$DEST_FILE"); my @reads = ; my $count=$#reads; my $curr_index= 0; while($curr_index <=$count) { my $line = $reads; $line=~s/^\s+|\s+$//g; if ( nil ne $line && "" ne $line) {
print DESTFILE "$line\n"; } $curr_index++; } close DESTFILE; close SRCFILE; } else { print "Source file $SRC_FILE not found!\n"; }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。