if ($line =~ m/\b-|b(^[A-Z][a-z]+\s[A-Z][a-z]+$+?!0-9)\|b/) {print "$line";} #### if ( $line =~ m/ # match \b- # a word boundary followed by a - | # or ( # (beginning of capture) b # the letter "b" ^[A-Z] # a capital letter anchored at start of string # ...wait, what? at the beginning?