On 6/30/2004 5:20 PM, [EMAIL PROTECTED] wrote:

I have a log file with thousands of lines, some of those lines come in with garbage / binary data in them. The lines with that happening are junk and of no use to me I want to pattern match for the junk and simply do nothing with that line, all other lines get divided into 2 different output files.
The code that I have below will separate the lines into output files but does not take into account the garbage.
# Split the lines into the appropriate files.
while (<LOGFILE>) {
if ( (/JUNIPER/)||(/REDBACK/) ){
print DSL $_ ;
} else {
print DIALUP $_ ;
}
}
I have included one good line and one garbage line in this post, be aware though that outlook and other mail clients will convert the control characters in the garbage to single characters so the garbage lines below is not 100% accurate but you should get the jist.

try either:

/[:print:]/ && print "junk";

# or #

use utf8;
/\p{IsPrint}/ && print "junk";

see `perldoc perlre` for info on POSIX & Unicode character classes.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to