Instead of taking filename from alt take it from the end of the src URL.
# Obtains all individual comic data
sub getComicData {
my $siteData = get("$sitePrefix$current/");
my @data = split /\n/, $siteData;
foreach (@data) {
if (/http:\/\/xkcd.com\/(\d+)\//) {
$current = $1;
}
#Instead of taking filename from alt
#take it from the end of the src URL
if (/src="(http:\/\/imgs.xkcd.com\/comics\/(.+\.\w{3}))"/) {
$currentUrl = $1;
#if (/alt="(.+?)"/) {
# $title = $1;
# $title = "House of Pancakes" if $current == 472; # Color title on comic 472 with weird syntax
#}
$title = $2;
say "File to save: $title";
if (/title="(.+?)"/) { #title commonly know as 'alt' text
$alt = $1;
}
}
}
}