作者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