7 my $p = Getopt::Long::Parser->new(config => [qw( gnu_getopt no_ignore_case )]);
8 my $opts = { profile => 'console', help => \&showhelp };
9 $p->getoptions( $opts, qw(
16 Pod::Usage::pod2usage( -verbose => 0, -exitval => 2 );
19 require SQL::Abstract::Tree;
20 my $sqlat = SQL::Abstract::Tree->new({ profile => $opts->{profile}, fill_in_placeholders => 0 });
25 $chunk = $leftover . $chunk if length $leftover;
27 if ($chunk =~ / \A (.+?) (?:
28 (?<=\S)\:\s+\'[^\n]+ # pasting DBIC_TRACE output directly
34 ^ \s* (?=SELECT|INSERT|UPDATE|DELETE)
38 print $sqlat->format($1);
44 } while ( (read *STDIN, $chunk, 4096) or length $leftover );
48 sqla-format - An intelligent SQL formatter
52 ~$ sqla-format << log.sql
54 ~$ myprogram -v | sqla-format -p html > sqltrace.html
56 =head1 COPYRIGHT AND LICENSE
58 This software is copyright (c) 2014 by Arthur Axel "fREW" Schmidt.
60 This is free software; you can redistribute it and/or modify it under
61 the same terms as the Perl 5 programming language system itself.