#! /usr/bin/perl use autodie; use POSIX qw{:errno_h}; use JSON; my ($dir) = @ARGV; eval { mkdir $dir; }; die if $@ && $@->errno != EEXIST; local $/; my $js = decode_json ; for my $e (@$js) { open $fh, ">", "$dir/$e->{name}.css"; print $fh "/* -*-css-*- */\n"; for my $s ($e->{sections}->@*) { KEY: for my $k (keys %$s) { next KEY if $k eq "code"; print $fh "/*@ $k: ", join(", ", $s->{$k}->@*), " */\n"; } $s->{code} =~ s/\n$//; print $fh $s->{code}, "\n"; print $fh "/*\@END*/\n"; } close $fh; }