...snip... if( $string =~ /foobar/ ) { $match = $1 unless undef then $match = "chiapet"; ]