use strict; use warnings; use feature 'say'; while () { say $1 if /#augment:(?:A|B)(.*)/; } __DATA__ First line of the file used for filler #augment:A Something One Another line of text for filler #augment:B Something Two Last line of the file used for filler #### 13:20 >perl 1350_SoPW.pl Something One Something Two 13:21 >