#!/usr/bin/perl -w open FILE ,"text.txt"; read(FILE,$text,-s "text.txt"); print $text; $text =~ s/\n\s+//s; print $text; |
#!/usr/bin/perl -w use strict; my $file; open (FILE,"file")or die "can't open file $:!"; my @file=<FILE>; close(FILE); open (OUTFILE,">>out")or die "can't open out $:!"; foreach $file(@file){ if($file =~ /[a-z]/){ $file =~ s/\n//; print OUTFILE $file; } else{ $file =~ s/\s+//; print OUTFILE $file; } } |
原帖由 redmaple_v1 于 2009-3-25 16:27 发表
[quote]原帖由 redmaple_v1 于 2009-3-25 15:44 发表
next,可以进行多行了,并写入一个文件中。
#!/usr/bin/perl -w
use strict;
my $file;
open (F ...
原帖由 which 于 2009-3-25 16:43 发表
我也仿照你的写了一个
cat chop.pl
#!/usr/bin/perl -w
use strict;
$^I = ".bak";
while()
{
unless(/[a-z]/){
$_ =~ s/\s+//;
print; ...
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |