Skip to content

Instantly share code, notes, and snippets.

@ap
Created January 20, 2010 02:11
Show Gist options
  • Save ap/281527 to your computer and use it in GitHub Desktop.
Save ap/281527 to your computer and use it in GitHub Desktop.
use 5.010;
use strict;
use SQL::Beautify;
my $sql = do { local $/; <> };
$_ = do {
my $p = SQL::Beautify->new;
$p->query( $sql );
$p->beautify;
};
s{ \(\s* (\d+) \s*\) (?:\s*(\w))? }
{ "($1)" . ( $2 ? " $2" : "") }gsex;
s{ (\)) \n ([;,]) }{ $1 . $2 }gex;
say;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment