作者handsomegirl (薰)
看板Perl
标题[问题] 关於插入空行
时间Thu May 22 17:30:26 2008
现在有个档案~因为格式的关系
想要在第21行插入三行空白行
有办法可以做吗???
因为我现在插入空行的方式,他会让每一行中间都隔了三行
谢谢大家指教~
chdir "c:\\Perl\\Cp";
@muti=glob("*.t*");
foreach (@muti)
{
open (FILE,$_);
@file=<FILE>;
close FILE;
foreach $file(@file)
{
open f,">>c:\\Perl\\Cp\\new\\$_";
$no=10;
while(chomp $file){
if($file!~/^\d\d\s/){
for (reverse @array){
print f $no++;
print f "\n\n\n";
print f " ".$_.$/ ;
}
print f "$file\n" ;
undef @array;
next ;
}
undef @s_line;
push @s_line,reverse@{[split//,$file]}[2..$#{[split//,$file]}];
push @array,join('',@s_line);
}
}
}
close f;
--
出清衣柜中~~欢迎参观
http://class.ruten.com.tw/user/index00.php?c=&m=&o=&p=&s=jwce1021
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.65.55.161
1F:推 hajimels:please show your code 05/22 17:37
※ 编辑: handsomegirl 来自: 61.65.55.161 (05/22 17:44)
2F:→ handsomegirl:不好意思~附上code了 05/22 17:44
3F:→ hajimels:你把印3行写在回圈里了呀.... 05/22 20:50
4F:→ hajimels:写个counter在外头 做一次就+1 05/22 20:51
5F:→ hajimels:再写个if当counter=20才会印那3行空白就好了 05/22 20:52
6F:→ handsomegirl:感恩~~~ 05/23 09:28