while (<>) {
....
}
...which gets a line at a time, explaining why adding one more character after your regex fails. I put your data into a file named /tmp/corpus.txt and did this, which worked:
cat /tmp/corpus.txt | perl -le '$_ = join("", <>); \
print $& if /CONNAME\((\d{1,3}(\.\d{1,3}){3})\)\s*CURRENT\s*CHL/;'
CONNAME(163.231.99.129) CURRENT
CHL
The different regex (\d{1,3}(\.\d{1,3}){3}) is slightly better at validating an IP address. Probably not essential unless you think your data might get munged; it could still match bogus things like "999.99.9.999", but it'll filter out bits like "1.2.3.4.5" or "2555.254.0.3".
Note that loading $_ like that is often frowned upon; you might consider:
my $corpus = join("", <>);
print $&
if $corpus =~ /CONNAME\((\d{1,3}(\.\d{1,3}){3})\)\s*CURRENT\s*CHL/;
Hope that helps!
--j |