CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
check files to see if they contain a specific phrase

 



roe1and
Novice

Nov 8, 2007, 3:22 AM

Post #1 of 2 (2642 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)


KevinR
Veteran


Nov 8, 2007, 9:55 AM

Post #2 of 2 (2635 views)
Re: [roe1and] check files to see if they contain a specific phrase [In reply to] Can't Post

yes, use unlink() to delete a file.
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives