Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Delete Lines Across Multiple Files

by tybalt89 (Prior)
on Jan 01, 2021 at 15:37 UTC ( #11126081=note: print w/replies, xml ) Need Help??


in reply to Delete Lines Across Multiple Files

Alternate with "missing file" protection.

#!/usr/bin/perl use strict; use warnings; use Path::Tiny; my $delroad = 'Some Road Name'; my $delnumber = 123; for my $file ( qw( file1 file2 ... file3 ) ) # your filenames here { eval { path($file)->edit_lines( sub { my @field = split /:|\n/; $field[1] eq $delroad && $field[2] == $delnumber and $_ = ''; } ); 1; } or print $@; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11126081]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2021-02-27 16:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?