in reply to Re^4: Regular expression match in code
in thread Regular expression match in code

Try to inspect your data with
use Data::Dumper; $Data::Dumper::Useqq = 1; print Dumper $var; print Dumper \@allServers;

You might have some non-printable characters either in the server list or in $var that prevent you from getting matches.

Replies are listed 'Best First'.
Re^6: Regular expression match in code
by truptivk (Novice) on May 12, 2010 at 09:45 UTC
    Surprise surprise,
    print Dumper \@allServers; print Dumper \@bigArray;
    prints nothing; just  $VAR1 = []  print Dumper $var; correctly prints the IP present in the incoming SNMP trap. So my reading from file part is going wrong?! How? Its fairly straight forward and I have even tested it by writing  exit(0); after the read from config (populates @allServers) and write into @bigArray (<ip,server>) format. Help... :(
      The easist explanation is that your open call fails. Since you don't check the return value, it does that silently.
      open my $fh, '<', $configFile or die "Can't open '$configFile' for reading: $!"; my @allServers; while (<$fh>) { push (@allServers, $_) if /^\w/; } close $fh or warn "Error while closing file: $!";
      Perl 6 - links to (nearly) everything that is Perl 6.