if ( /\b(API|APIN|UWI)\s*\./ ) { $myvar = $1 } # $1 is set to whatever was matched inside the parens # (if there were more than 1 set of parens, additional # paren'ed strings would be set to $2, $3...