-# 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>/;
+
+if (/>Browser engines/ ... m{</table>}) {
+ my $apple = $id =~ s/^AppleWebKit ?//;
+ $apple .. 1 or next;
+ my ($abs) = m/>showCount\((\d+),/;
+
+ state %version;
+ if (defined $count2) {
+ $version{$id} = $abs;
+ next;
+ }
+
+ # replace safari total percentage by individual version counts
+ # have to use combined distribution for multiple platforms :(
+ for my $browser (qw/ safari ios_saf /) {
+ my $multiplier = delete $count{$browser}{'0.0'} or next;
+ $multiplier /= $abs; # total number
+ while (my ($verwebkit, $count) = each %version) {
+ my $ver = safariver($verwebkit, $browser eq 'ios_saf');
+ $count{$browser}{$ver} += $count * $multiplier;
+ }
+ }
+ last;
+}
+
+# select version data
+/>Browser versions(.*)/ ... !defined $count2 or next;
+unless (defined $count2) {
+ # header row if no td separator
+ $mobile = $id !~ /non mobile/;
+ next;
+}