Add after line 5..
use HTML::Entities; or use HTML::Entities qw(decode_entities);
.....

$new_url = decode_entries($embed_url);
....

This converts all &#nnn; - &amp; to their characters..

The s/&#038;/.... only converts one specific case. this is more general s/&#(d+);/chr($1)/eg,
but does not cover &amp; type cases, decode_entities does it all.

Not sure why you would need to do this, need examples of why it's needed. Or reget the page.