Re: [請益] 文字檔案中插入新文字.....

看板Perl作者 (可愛中央處理器)時間19年前 (2006/05/31 17:09), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
#!/usr/bin/perl open FILE,"test.txt"; $s=<FILE>."ABCABC\n"; $s.=$_ while(<FILE>); close FILE; open FILE,">test.txt"; print FILE $s; close FILE; ※ 引述《jacklinxp (開始工作)》之銘言: : 有一個文字檔假設內容為 : AAAAAA : DFDFDSF : BSDFDSF : BSDFSD : 如果我要在AAAAAA : 後面新增文字的話,要如何去開檔或者寫入呢? : 因為如果我用 : open FILE, ">> text.txt"; : 並在程式中使用print FILE, "ABCABC\n" : 結果會是 : AAAAAA : DFDFDSF : BSDFDSF : BSDFSD : ABCABC : 而不是我想要的 : AAAAAA : ABCABC : DFDFDSF : BSDFDSF : BSDFSD : 請問要如何達到我想要的結果呢?有特別的function可以使用嗎? : 多謝大家的幫忙 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.63.246.28
文章代碼(AID): #14VLqxsA (Perl)
文章代碼(AID): #14VLqxsA (Perl)