>>525>>528 Perl5
sub na { (((($_[0] << 8) + $_[1]) << 8) + $_[2]) << 8 + $_[3] }
sub iaf { my @rl;
 for (split "\n", shift) {
  my @f = /(?:(allow|deny)\s+)?(\d+)\.(\d+)\.(\d+)\.(\d+)(?:\/(\d+))?/;
  if ($f[0]) {
   push @rl, [$f[0], na(@f[1..4]), $f[5]//0];
  } else {
   $res = 'allow';
   for (@rl) { $res = $$_[0] if ($$_[1] & $$_[2]) == (na(@f[1..4]) & $$_[2]) }
   print "$_ -> $res\n";
  }
 }
}
iaf <<EOL;
allow 192.168.11.9
deny 192.178.12.3/8
allow 192.168.23.34/16
192.168.89.99
EOL
iaf <<EOL;
deny 0.0.0.0/0
allow 20.8.5.34
20.8.5.34
EOL

実行結果
~ $ perl 17_525_ip_filt.pl
192.168.89.99 -> allow
20.8.5.34 -> allow