Re: [請益] 關於寫入txt檔
※ 引述《h781005 (龜小C)》之銘言:
: 想請問各位高手
: 小弟我現在如果想要請使用者將資料輸入後
: 寫入txt檔裡面存放
: 但是又不想要在執行第二次時把第一次的資料覆蓋掉
: 要怎麼做修改
: 以下是我的code
: #!/usr/bin/perl -w
: my %tel;
: print "Enter name:";
: my $input = <>;
: print "Enter number:";
: my $number = <>;
: $tel{$input} = $number;
: open FILE, ">telephone2.txt";
: for (keys %tel) {
: print FILE "$_$tel{$_}\n";
: }
: close FILE;
: 先在此感謝各位!!
再問一個問題...
假設我現在輸入之後想要讀取檔案中所有資料
我照著網路上的打
#!/usr/bin/perl -w
open FILE, "telephone.txt" or die "開啟檔案失敗: $!";
while () {
print $_;
}
close FILE;
結果出現一個問題
Use of uninitialized value in print at xx.pl line 8
請問這樣要怎麼做修改阿?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.230.4.155
→
07/11 14:14, , 1F
07/11 14:14, 1F
→
07/11 14:17, , 2F
07/11 14:17, 2F
→
07/11 14:18, , 3F
07/11 14:18, 3F
→
07/16 12:18, , 4F
07/16 12:18, 4F
討論串 (同標題文章)