in reply to Regex question

You may have missed it, but based on your description and the subsequent discussion thelenm already gave you your answer.

$match = $string =~ /foobar/ ? $1 : "chiapet"; ... the rest of your code goes here ...

Although you may want to consider what you're doing; "chiapet" is harder to check if you have code that does something slightly different if the value was defaulted. On the other hand, undef is much easier to check.

Depending on your regex you may also lose information by defaulting it, which may be undesireable; where undef is easy to distinguish (a string can't contain undef), defaulting the value will be indistinguishable from "chiapet" in the string itself.