#!/usr/bin/perl # cssalign: fix alignment in CSS files. while (<>) { chomp; # handle opening and closing brackets s/{ */{/g; s/ *{/ {\n /g; s/ *}/}/g; # handle colons and semicolons; # try to avoid turning "a:hover" into "a: hover" by # looking for two characters before a colon. s/; */;/g; s/ *;/;\n /g; s/;\n $//g; s/(\S\S\S*):/$1: /g; # cleanup s/ *}/}\n/g; s/: */: /g; print "$_\n"; } exit (0);