if (my ($prefix, $matched, $suffix) = /^(.*?)"(.+?)"(.*)/) { $matched = ... # Do what you need. print qq($prefix"$matched"$suffix\n); }