in reply to Cant help print key word
I think it would be easier if you used index() because the IP addresses have '.'s in them which mean 'match any character'.
use feature ":5.14"; use warnings FATAL => qw(all); use strict; use Data::Dump qw(dump pp); my $i = "10.0.0.132"; say for grep {index($_, $i) != -1} split /\n/, << 'END'; a.AS1 10.0.0.128 b.AS1 10.0.0.129 c.AS1 10.0.0.130 d.AS1 10.0.0.131 e.AS1 10.0.0.132 END
Produces
e.AS1 10.0.0.132
|
|---|