Chas. Owens wrote:
On Sun, Apr 13, 2008 at 2:05 PM, Richard Lee <[EMAIL PROTECTED]> wrote:
snip
           next if ! /^$start/;
snip

You should say

next unless /^$start/o;

The o makes a promise that $start won't change, so the regex only gets
compiled once (it is recompiling the regex each time through the loop
currently) and unless is easier to see than "if !" when reading code
quickly.

snip
           next if ! m{
                       .+\s+D\s+
                      udp\s+
                      \d+\.\d+\.\d+\.\d+\s+
                      \d+\.\d+\.\d+\.\d+\s+
                      \d+\s+\d+\s+
                       .+
                     }xms;
            push @bad, join('_', ( split( /\s+/, $_))[10,12,11,13,9,8]);
snip

Why are you making sure the data is right and then pulling the data
you want out?  Do both at the same time with captures, or better yet,
since you don't do anything more with $_, just use a substitution and
push $_ onto @bad (cuts out yet another function).

I will try the /o option.
But I am not 100% sure what you are saying on " Why are you making sure the data is right and then pulling the data you want out? " ? I need to move onto next data if it doesn't conform to 2nd regex and then I am extracting only certain field and join them by _ and pushing them into array.


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


Reply via email to