Millhost said: > Dear All > > I am using this script to get my maillog information > > ## > %IP_LOG=(); > open (LOG,/var/log/maillog); > foreach (<LOG>) { > if (/Sep 20/) { > $IP_LOG{$_}++; > } > } > ## > I found this script will take 3-4 second when my log file in 40MB > But I try using gerp "Sep 20" /var/log/maillog in bash shell, it take 0.8 > sec only. > > Did any one know how to optimize the script to have better performance.
Like this from Learning Perl: #!/usr/bin/perl -w use strict; while (<>) { chomp; if (/Sep 20/) { print "Matched: |$`<$&>$'|\n"; # Mystery code! See the text. } else { print "No match.\n"; } } > > Thanks all > > -- > > > --------------------------------------------------------------------- > "Are you still wasting your time with spam?... > There is a solution!" > > Protected by GIANT Company's Spam Inspector > The most powerful anti-spam software available. > http://mail.spaminspector.com > > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>