File: pg_format

package info (click to toggle)
pgformatter 5.6-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 7,920 kB
  • sloc: sql: 185,796; perl: 4,793; makefile: 2; sh: 1
file content (51 lines) | stat: -rwxr-xr-x 1,307 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl

use strict;
use warnings;
use warnings qw( FATAL );
use Encode qw( decode );

if ( grep /\P{ASCII}/ => @ARGV ) {
    @ARGV = map { decode( 'UTF-8', $_ ) } @ARGV;
}

# UTF8 boilerplace, per http://stackoverflow.com/questions/6162484/why-does-modern-perl-avoid-utf-8-by-default/

# Improve warning/exception handling
use Carp qw( carp croak confess cluck );

# give a full stack dump on any untrapped exceptions
local $SIG{ __DIE__ } = sub {
    confess "Uncaught exception: @_" unless $^S;
};

# now promote run-time warnings into stackdumped exceptions
#   *unless* we're in an try block, in which
#   case just generate a clucking stackdump instead
local $SIG{ __WARN__ } = sub {
    if   ( $^S ) { cluck "Trapped warning: @_" }
    else         { confess "Deadly warning: @_" }
};

# Improve warning/exception handling

# Find libraries path (should be in lib/ directory of where binary is, or on system perl library directory
use FindBin;
use lib "$FindBin::RealBin/lib";

our $VERSION = '5.3';

# Find out whether current run should be treated as CGI or CLI
my $program;
if ( $ENV{ 'GATEWAY_INTERFACE' } ) {
    require pgFormatter::CGI;
    $program = pgFormatter::CGI->new();
}
else {
    require pgFormatter::CLI;
    $program = pgFormatter::CLI->new();
}

$program->run();

exit 0;