Skip to content

Instantly share code, notes, and snippets.

@tomgidden
Created March 20, 2013 00:04
Show Gist options
  • Save tomgidden/5201283 to your computer and use it in GitHub Desktop.
Save tomgidden/5201283 to your computer and use it in GitHub Desktop.
TrimPHP: removes whitespace from EOF, EOL, and pointless ?>'s from EOF
#!/usr/bin/perl
while(<>) {
s/\s+$//s;
push @l,$_;
if(eof) {
($b=join("\n",@l))=~s/\s*(\?>)?\s*$/\n/s;
print $b;
undef @l;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment