in reply to limiting regular expression greediness?

Instead of a non-greedy qualifier, you can use a negative look-behind assertion to get your replacement right. (See perlre)

$xml =~ s#\t<element attribute='$name'>(?:.(?<!</element>))*</element> +\n#$node#s;

Side note: the /s modifier is not needed here.