Or the file could be read and written in one action, and the deletion can be handled by a simple substitution.
#! /usr/bin/perl -w use strict; my $valueToDelete = "two 222 sld"; my $content = ''; open my $fh, 'oldfile' || die $!; do {local $/; $content = <$fh>}; close $fh; $content =~ s/^$valueToDelete\n//m; open $fh, '>newfile' || die $!; print $fh $content; close $fh;
In reply to Re: deleting lines from file
by pbeckingham
in thread deleting lines from file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |