Actually, you can do exactly the same thing in Perl, although it's considered stylistically sucky and is a hazard to security if there are variables that mischievous users can set to evil values.
$x=`cat <<endl | grep whatever
yadda yadda
whatever
yadda yadda
endl`;
chomp $x;
print qq{\$x="$x"\n};