From: Ken Youens-Clark Date: Wed, 15 Oct 2003 20:07:11 +0000 (+0000) Subject: Trying to get sqlt to play nicely with DBI parsers which need no input file. X-Git-Tag: v0.04~58 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b79348f4be463bc4a37057c6607dec3611148e74;p=dbsrgits%2FSQL-Translator.git Trying to get sqlt to play nicely with DBI parsers which need no input file. --- diff --git a/bin/sqlt b/bin/sqlt index a2750d8..962bad6 100755 --- a/bin/sqlt +++ b/bin/sqlt @@ -2,7 +2,7 @@ # vim: set ft=perl: # ------------------------------------------------------------------- -# $Id: sqlt,v 1.8 2003-10-14 17:03:45 kycl4rk Exp $ +# $Id: sqlt,v 1.9 2003-10-15 20:07:11 kycl4rk Exp $ # ------------------------------------------------------------------- # Copyright (C) 2002 Ken Y. Clark , # darren chamberlain @@ -113,7 +113,7 @@ use Pod::Usage; use SQL::Translator; use vars qw( $VERSION ); -$VERSION = sprintf "%d.%02d", q$Revision: 1.8 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.9 $ =~ /(\d+)\.(\d+)/; my $from; # the original database my $to; # the destination database @@ -169,7 +169,14 @@ GetOptions( ) or pod2usage(2); my @files = @ARGV; # source files -@files = ('-') unless (@files); +unless ( @files ) { + if ( $from eq 'DBI' ) { + @files = ('!'); + } + else { + @files = ('-'); + } +} pod2usage(1) if $help; @@ -223,9 +230,14 @@ $translator->parser($from); $translator->producer($to); for my $file (@files) { - my @args = ($file eq '-') ? (data => \*STDIN) : (file => $file); + my @args = + ($file eq '-') ? (data => \*STDIN) : + ($file eq '!') ? (data => '') : + (file => $file); + my $output = $translator->translate(@args) or die "Error: " . $translator->error; + print $output; }