#!/opt/bin/perl ######################################################################### # # # Program for finding certain mails in certain mailfolders # # # ######################################################################### # # # Version 1.1 - Written 11.11.96 by Steffen Beyer # # # ######################################################################### # # # Copyright (C) 1995 by software design & management GmbH & Co. KG # # # ######################################################################### # Default settings: $version = 'version 1.1'; $self = $0; $self =~ s!^.*/!!; $self =~ s!\.suid$!!; $argc = @ARGV; $argx = 1; # Check for options: while ($ARGV[0] =~ /^-./) { if (($ARGV[0] eq '-il') || ($ARGV[0] eq '-li')) { shift; $ignore_case = 1; $print_filename = 1; $argx++; next; } elsif ($ARGV[0] eq '-i') { shift; $ignore_case = 1; $argx++; next; } elsif ($ARGV[0] eq '-l') { shift; $print_filename = 1; $argx++; next; } else { warn "\n"; warn "$self: unknown option '$ARGV[0]'!\n"; &usage; exit(1); } } # Check number of arguments and issue usage: if ($argc != $argx) { &usage; exit(1); } $search = shift; eval { /$search/o }; if ($@) { warn "\n"; warn "$self: not a valid regular expression in Perl: '$search'!\n"; warn "\n"; warn "See 'man perlre' for details!\n"; &usage; exit(1); } print "Searching preport matching pattern '$search'...\n"; unshift(@INC, '/opt/lib/problem'); require "config.pl"; # Configure here the name(s) of your problem report folder(s): push(@list, 'preport'); push(@list, 'zurueck'); push(@list, 'erledigt'); &configure(); push(@list, @files); $found = 0; # Loop through list of folders: for ( $i = 0; $i <= $#list; $i++ ) { $file = $list[$i]; if (open(FOLDER, "<$path/$file")) { while () { if ((($ignore_case) && (/$search/io )) || ((!$ignore_case) && (/$search/o))) { $found = 1; if ($print_filename) { print "preport matching pattern '$search' found in folder '$file'\n"; last; } else { print "$file: $_"; } } } close(FOLDER); } else { warn "$self: can't read folder '$file': $!\n"; } } unless ($found) { print "No preport found matching pattern '$search'\n"; } exit(0); sub usage { warn "\n"; warn "$self $version\n"; warn "\n"; warn "Usage: $self [ -i ] [ -l ] \n"; warn "\n"; warn "(Option '-i' means 'ignore case')\n"; warn "(Option '-l' means 'list filenames only')\n"; warn "\n"; } __END__