+#!/usr/bin/env perl
+use 5.010;
+use strict;
+use warnings;
+
+use Data::Dump 'pp';
+use File::Slurp 'read_file';
+use JSON;
+
+local $/; # slurp
+my $source = readline;
+
+for ($source) { # cleanup
+ # convert seperate variables to hash keys
+ s/\A/{/;
+ s/^caniuse\.(\w+) = /"$1":/gm;
+ s/;$/,/gm;
+ s/,\s*\Z/\n}/;
+ # fractions not supported by barekey
+ s/(?<=[,{]) (\d*\.\d) (?=:')/"$1"/gx;
+ # escapes not supported in singlequote
+ s{'((?:[^\\']+|\\.)*)'}{
+ my $_ = $1;
+ s/"/\\"/g;
+ s/\\'/'/g;
+ qq("$_");
+ }ge;
+}
+
+my $data = from_json($source, {
+ allow_singlequote => 1,
+ allow_barekey => 1,
+});
+
+print pp($data);
+
+__END__
+
+=head1 NAME
+
+convert-caniuse - Turn Javascript data into an equivalent Perl structure
+
+=head1 SYNOPSIS
+
+ curl http://caniuse.com/js/data.js |
+ tools/convert-caniuse.pl > browser-support.inc.pl
+