in reply to deleting lines from file

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;

Replies are listed 'Best First'.
Re: Re: deleting lines from file
by phenom (Chaplain) on Mar 18, 2004 at 03:03 UTC
    Yup, I like that one better than my array solution.