Alphabetical column contains more versions (due to phone and tables counts
being combined?). More reliable matching.
-use 5.010; use strict; use warnings;
+use 5.012;
+use warnings;
if (m{<td class=hl>} .. m{</?td>}) {
$count{-source} = 'http://stats.wikimedia.org/archive/squid_reports/';
if (m{<td class=hl>} .. m{</?td>}) {
$count{-source} = 'http://stats.wikimedia.org/archive/squid_reports/';
-# select relevant columns
-/>Browser versions(.*)/ ... m{</table>} && last or next;
-my ($tr, $id, $count2, $count) = split /(?:<[^>]*>)+/;
-$mobile = $count2 !~ /non mobile/ if $id ~~ ' ';
-next if $id ~~ ['Total', ' '];
+# select relevant data
+/>In alphabetical order/ .. eof or next; # second table
+my ($id, $count2, $count) = map { s/<[^>]*>//gr } split /<\/td>/;
+
+# select version data
+/>Browser versions(.*)/ ... !defined $count2 or next;
+unless (defined $count2) {
+ # header row if no td separator
+ $mobile = $id !~ /non mobile/;
+ next;
+}
# convert to usable syntax
# convert to usable syntax
-my ($browser, $version) = split /\h+/, $id, 2;
+my ($browser, $version) = split /\h+/, $id || ' ', 2;
$count =~ s/,//g;
$count =~ s/%$//;
$version //= 0;
$count =~ s/,//g;
$count =~ s/%$//;
$version //= 0;