while (<>) { .... } #### 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 #### my $corpus = join("", <>); print $& if $corpus =~ /CONNAME\((\d{1,3}(\.\d{1,3}){3})\)\s*CURRENT\s*CHL/;