Most probably I'm missing something obvious here, but why do I need to call the search/replace regex twice to have any effect in the following code? If I call it only once, the replacement doesn't take place :-(
use strict;
use warnings;
use LWP::Simple;
my $youtubeCN = get(shift @ARGV);
die("Script tag not found!\n")
unless $youtubeCN =~ /<script src="(.*?)">/;
my $youtubeScr = $1;
# WHY ???
$youtubeScr =~ s/&/&/g;
$youtubeScr =~ s/&/&/g;
my $gmodScr = get($youtubeScr);
$gmodScr =~ s/http:\/\/\?container/http:\/\/www.gmodules.com\/ig\/ifr\?/;
print "<script type=\"text/javascript\">$gmodScr</script>\n";
Update: I call this script like this:
perl bork_youtube_channel.pl 'http://www.youtube.com/user/pennsays'
If amp isn't properly transformed into &, I will get back an HTML page (probably an error page) rather than Javascript at step 2.
Update: It turns out that the URL was double encoded after all. Thank you all for your help!