in reply to Grep file before sending through socket
Since you need to open the file before grepping it, try something like
where $errors is a regular expression that you set up in advance with the patterns that mean "error" to you. (Or, you can hard-code it). The /m on the regex allows you to use ^ and $ to match lines within $file.open FILE, "$senddir/$file" or die "$senddir/$file: $!" my $file = do { local $/; <FILE> }; close(FILE); if ( $file =~ m/$errors/mo ) { # move the file } else { # open the socket and send $file, as before } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Grep file before sending through socket
by wileykt (Acolyte) on Dec 11, 2001 at 20:46 UTC | |
by dws (Chancellor) on Dec 11, 2001 at 22:45 UTC |