
roe1and
Novice
Nov 8, 2007, 3:22 AM
Post #1 of 2
(2249 views)
|
check files to see if they contain a specific phrase
|
Can't Post
|
|
i hardly understand php and now the work wants me to dick about with perl! i'm desperately looking for a script that will run through a directory and it's subdirectories looking at xml files and if the file does not contain the tag: <APS_content> it has to be deleted. any help will be welcome. if someone could please just point me in the right direction that would be appreciated. so far, this is recycled code from another perl script, i've come up with this 1. read all the filenames into an array called my $filename 2. shift is neat ill have to loop this somehow???: my $filename = shift; open(my $input, "<$filename" ) or return ""; while( <$input> ) { return 1 if /<APS_content>/; #if it doesn't contain <APS_content> i'd like to delete the file ( unlink()?) }
(This post was edited by roe1and on Nov 8, 2007, 3:51 AM)
|