Consider:
use strict; use warnings; my $testFile = 'delme.txt'; unlink $testFile; open my $ioFile, '>', $testFile or die "Failed to open $testFile for u +pdate: $!\n"; print $ioFile "This is some output text\n"; my $seekBackPoint = tell $ioFile; print $ioFile "This line will get overwritten (at least partially)\n"; seek $ioFile, $seekBackPoint, 0; print $ioFile "Overwrite part of a line.\n"; close $ioFile; open my $iFile, '<', $testFile or die "Failed to open $testFile for re +ading: $!\n"; print <$iFile>; close $iFile;
Prints:
This is some output text Overwrite part of a line. ten (at least partially)
Note: use lexical file handles and the three parameter version of open.
In reply to Re: Read and write files concurrently in Perl
by GrandFather
in thread Read and write files concurrently in Perl
by sselva
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |