This should be a weekly thing :
See who can send in the most useful Perl one liner!

So to start it off, I would like some suggestions on some "not so
cryptic" one liner methods to do the following :

#!/usr/bin/perl -w
use strict;

opendir(TEMP_DIR, "/home/slutz/temp");
        my @items = grep(/\.BAD/,readdir(TEMP_DIR));
closedir(TEMP_DIR);

my ($file, $line);

foreach $file (@items) {
        print "Going into file : $file\n";
        open(FIN, $file) || warn "cant open the damn file : $!";
        while ( $line = <FIN> ){
                if ( $line =~ m'[EMAIL PROTECTED]' ) {
                        rename "/home/slutz/temp/$file",
"/home/slutz/temp/bad_email/$file" || die "$!";
                        print "moved file /home/slutz/temp/$file to
/home/slutz/temp/bad_email/$file\n";
                }
        }
        close(FIN);
}


Thanks in advance!


Scott Lutz
Pacific Online Support
Phone: 604.638.6010
Fax: 604.638.6020
Toll Free: 1.877.503.9870
http://www.paconline.net


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to