1#!/usr/bin/perl 2 3use strict; 4 5my $file = shift(); 6open FILE, "<$file"; 7my $txt = do { local $/; <FILE> }; 8 9# strip C99 comments 10$txt =~ s/\/\/.*//g; 11# strip newlines 12$txt =~ s/\n//g; 13# strip remaining comments 14$txt =~ s/\/\*.*?\*\///g; 15# strip tabs 16$txt =~ s/\t//g; 17# strip spaces 18$txt =~ s/ //g; 19# add newlines 20$txt =~ s/;/;\n/g; 21$txt =~ s/{/{\n/g; 22$txt =~ s/}/}\n/g; 23 24print "$txt\n"; 25