11 our $VERSION = '1.01';
14 my $source = readline;
16 for ($source) { # cleanup
17 s/\A\(// and s/\);?\s*\Z//; # empty callback
18 next if /^\{/; # valid json
20 # convert seperate variables to hash keys
22 s/^caniuse\.(\w+) *= */"$1":/gm;
25 # fractions not supported by barekey
26 s/(?<=[,{\n]) (\d*\.\d) (?=:['"])/"$1"/gx;
27 # escapes not supported in singlequote
28 s{: *\K'((?:[^\\']+|\\.)*)'}{
36 my $data = from_json($source, {
37 allow_singlequote => 1,
40 my $update = eval { stat(${^LAST_FH} // $ARGV)->mtime }
41 or warn "Could not determine input time\n";
42 $data->{-date} = Time::Piece->new($update)->datetime;
50 mkcaniuse - Turn Javascript data into an equivalent Perl structure
54 tools/mkcaniuse data.json >browser-support.inc.pl