if ( $string =~ m/(foobar)/ ) { $match = $1; } else { $match = "chiapet"; }