$line = "FAR PASCAL_CONV blurb"; my ($expr) = $line =~ m/(?:FAR PASCAL(?:_CONV)?) (.*)/i; # $expr now contains "blurb";