nt2282 has asked for the wisdom of the Perl Monks concerning the following question:
The contents of the file are not appended to the STDOUT. Please guide how to do that.use warnings; print "Enter the name of the file:\n"; $filename = <STDIN>; chomp($filename); open MYFILE, "$filename" or die "Error in opening: $!"; print "Enter your text:\n"; $new_text = <STDIN>; chomp($new_text); print "\nYour new file contains: $new_text\n"; open MYFILE, ">>$filename" or die "Error in opening: $!"; print MYFILE "$new_text\n"; while(my $line = <MYFILE>) { print "$line\n"; } close(MYFILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Contents of file not printed to STDOUT
by ikegami (Patriarch) on Jan 31, 2011 at 17:51 UTC | |
by nt2282 (Novice) on Jan 31, 2011 at 18:00 UTC | |
|
Re: Contents of file not printed to STDOUT
by Anonymous Monk on Jan 31, 2011 at 17:40 UTC | |
by AnomalousMonk (Archbishop) on Jan 31, 2011 at 18:26 UTC | |
by GrandFather (Saint) on Jan 31, 2011 at 20:16 UTC | |
by nt2282 (Novice) on Jan 31, 2011 at 17:46 UTC | |
by Anonymous Monk on Jan 31, 2011 at 17:49 UTC | |
by wfsp (Abbot) on Feb 01, 2011 at 08:45 UTC | |
|
Re: Contents of file not printed to STDOUT
by GrandFather (Saint) on Jan 31, 2011 at 20:24 UTC |