in reply to Objectionable reference

You are discarding the results from the "..{fw}->obj" call in
} else { print "Help Me\t" . $line->source_str . "\n"; my @sources = $configs{$fw}->obj($line->source +_str); }
because you declare a new block-scoped my @sources within the block.

     Theory is when you know something, but it doesn't work.
    Practice is when something works, but you don't know why it works.
    Programmers combine Theory and Practice: Nothing works and they don't know why.         -Anonymous

Replies are listed 'Best First'.
Re^2: Objectionable reference
by vectorvillain (Novice) on Dec 11, 2009 at 20:46 UTC
    The issue existed before I put in the Help Me check. Based on your suggestion I returned that output of $line->source_str into a scalar and tested everything from there:
    $tmp = $line->source_str; if ($tmp =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) { push @sources, $tmp; } else { # print "Help Me\t" . $line->source_str . "\n"; my @sources = $configs{$fw}->obj($tmp); }

    With these changes in my unsanitized script, I got the same results.

    Edit:

    I re-read your post. When I don't use my @sources = I seem to get the entire firewall object (i.e. the object referenced in $configs{$fw}), rather than the array of the address that should be held in $configs{$fw}->obj($tmp). That's why I put the my in in the first place. Is there a better way to deal with that issue?

      I'm having trouble understanding your intent - what do you want to do if $tmp does not match an IPv4 address pattern ?

      Adding $tmp did not change the flow, or logic.

      It may be more helpful to print

      #REPLACE THIS# print "Help Me\t" . $line->source_str . "\n"; print "IPv4 not matched in line\[" .$line->print() . "] str=". $line- +>source_str . ";\n";
      Yes - the "->obj()" method will return an object. What attribute of that object did you need to extract ?

      I also noticed another place where you are throwing away information the same way as my @source:

      } else { my @protos = $configs{$fw}->obj($line->proto_str) }
      Here, the block-scoped @protos is thrown away.

           Theory is when you know something, but it doesn't work.
          Practice is when something works, but you don't know why it works.
          Programmers combine Theory and Practice: Nothing works and they don't know why.         -Anonymous