Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How can I delete a matchine line from a file?
tie my @file, 'Tie::File', $file or die 'Could not open file'; for (@file) { if (/matching_line/) { I need to delete this matiching line } } untie @file;

Replies are listed 'Best First'.
Re: Delete a line from a file using Tie::File
by kcott (Archbishop) on Nov 02, 2010 at 01:02 UTC

    Replace your entire for block with:

    @file = grep { ! /matching_line/ } @file;

    -- Ken

      Thanks much Ken!
        The above solution worked but it takes much time to process it.. Looks like it need more memory..Is there any other way I can delete an element from a Tie::File array?