Hi,
I think this is a simple one but I guess I'm blind and need some help.
I have a directory full of files and want to look into each file for a
specific string, as soon as I found this I would like to do some actions
(move its to another folder) and go over to the next file. With the while
statement I always read through the whole file. Any suggestions?

==snip===
$badmail = "C:\\something";
$search = "some string";
opendir (h_dir, $badmail) or die "Can't open $badmail, $!\n";
        @dir = readdir h_dir;
        foreach $file (@dir) {
                if (-d $file) {next}
                else {
                        $flag = 0;
                        $filename = c_smtpssl_badmail.$file;
                        open h_file, "<$filename" or die "Can't open file
$filename, $!\n";
                        while (<h_file>) {
                                if (/$search/) {$flag = 1}
                                }
                        close h_file;
                        }
                if ($flag) {
                        move ($filename, $location1.$filename);
                        }
                else {
                        move ($filename, $location2.$filename);
                        }
                        }
        closedir h_dir;

==snip===
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to