Skip to content

Instantly share code, notes, and snippets.

@cliffwoo
Created November 17, 2013 09:41
Show Gist options
  • Save cliffwoo/7511358 to your computer and use it in GitHub Desktop.
Save cliffwoo/7511358 to your computer and use it in GitHub Desktop.
Remove comments and empty lines from source code
#!/usr/bin/perl
undef $/;
$text = <>;
$text =~ s/\/\/[^\n\r]*(\n\r)?//g;
$text =~ s/\/\*+([^*]|\*(?!\/))*\*+\///g;
$text =~ s/\n+/\n/g;
print $text;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment