Re: [請益] 文字檔案中插入新文字.....
#!/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
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
Perl 近期熱門文章
PTT數位生活區 即時熱門文章