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: Edit Log



roe1and
Novice

Nov 8, 2007, 3:22 AM


Views: 2616
check files to see if they contain a specific phrase

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)


Edit Log:
Post edited by roe1and (Novice) on Nov 8, 2007, 3:51 AM


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

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