Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Remove a line with a particular text

by reneeb (Chaplain)
on Sep 05, 2005 at 10:00 UTC ( [id://489184]=note: print w/replies, xml ) Need Help??


in reply to Remove a line with a particular text

#! /usr/bin/perl use strict; use warnings; use Tie::File; use File::Copy qw(copy); my $sourcedir = '/path/to/sourcedir/'; my $targetdir = '/path/to/targetdir/'; my @files = qw(file1 file2 file3); for my $file(@files){ copy($sourcedir.$file,$targetdir.$file); tie my @array,'Tie::File',$targetdir.$file or die $!; @array = grep{$_ !~ /Input/ && $_ !~ /Output/}@array; untie @array; }

Replies are listed 'Best First'.
Re^2: Remove a line with a particular text
by izut (Chaplain) on Sep 05, 2005 at 17:56 UTC
    You can substitute the @files array with glob:
    foreach my $file (glob "$sourcedir/Test*") { ... }


    Igor S. Lopes - izut
    surrender to perl. your code, your rules.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-25 16:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found