in reply to Re: Code optomization
in thread Code optomization

Ok, I've made some huge adjustments and code reduction. I've also applied use strict and use warnings. I'm getting one message in particular regarding the following:
for ($3) { /transparent/ && $info{clear} == 1 && do {$use_this = 1; last;}; /anonymous/ && $info{anonymous} == 1 && do {$use_this = 1; last;}; /highanonymity/ && $info{spranonymous} == 1 && do {$use_this = 1; + last;}; }
The actual warning:
Use of uninitialized value in pattern match (m//) at ./ProxyHunter.pl +line 93.
Using common sence i'm assuming that its raising an issue whenever only one of the 3 are matched. Would it be easier to use if/then statements?
Guns don't kill people, ninjas do.

Replies are listed 'Best First'.
Re^3: Code optomization
by sgifford (Prior) on Jul 08, 2004 at 21:18 UTC
    As you say, that probably happens when $3 isn't defined. Adding something like:
    defined || last;
    at the top of that for block would probably do the trick.
      or make the "loop" for (grep defined, $3)

      We're not really tightening our belts, it just feels that way because we're getting fatter.
      I'm sorry, I don't understand. Can you explain a bit more? ----
      Guns don't kill people, ninjas do.
        The problem is that you're trying to do a pattern match against an undefined variable (if the regex doesn't match, or doesn't match enough, $3 will be undefined). My solution drops out of the "loop" immediately in this case, so it never tries to do the pattern match. Roy Johnson's solution avoids entering the loop at all if $3 is undefined.