in reply to Writing to file and reading from same file


Here is one way to do it. Have a look at perlopentut as well.
#!/usr/bin/perl -w use strict; # Open file for reading and writing (and maybe arithmetic) open MYFILE, "+>somefile.txt" or die "Error message here: $!\n"; # Write to the file print MYFILE "These are the days\n"; print MYFILE "and these are the days\n"; # Rewind the file for reading seek(MYFILE, 0, 0); while (<MYFILE>) { print $_; } close MYFILE;

--
John.