$match = "chiapet"; # default value if ($string =~ /foobar(...)/) { # probably want to capture something here $match = $1; } #### $match = ($string =~ /foobar(...)/) ? $1 : "chiapet";