package SQL::Translator;
# ----------------------------------------------------------------------
-# $Id: Translator.pm,v 1.22 2003-04-17 23:16:28 allenday Exp $
+# $Id: Translator.pm,v 1.23 2003-04-19 23:32:34 allenday Exp $
# ----------------------------------------------------------------------
# Copyright (C) 2003 Ken Y. Clark <kclark@cpan.org>,
# darren chamberlain <darren@cpan.org>,
use base 'Class::Base';
$VERSION = '0.01';
-$REVISION = sprintf "%d.%02d", q$Revision: 1.22 $ =~ /(\d+)\.(\d+)/;
+$REVISION = sprintf "%d.%02d", q$Revision: 1.23 $ =~ /(\d+)\.(\d+)/;
$DEBUG = 0 unless defined $DEBUG;
$ERROR = "";
if (-d $filename) {
my $msg = "Cannot use directory '$filename' as input source";
return $self->error($msg);
+ } elsif (ref($filename) eq 'ARRAY') {
+ $self->{'filename'} = $filename;
+ $self->debug("Got array of files: ".join(', ',@$filename)."\n");
} elsif (-f _ && -r _) {
$self->{'filename'} = $filename;
$self->debug("Got filename: '$self->{'filename'}'\n");
local $/;
my $data;
- unless (open FH, $filename) {
- return $self->error("Can't read file '$filename': $!");
- }
+ my @files = ref($filename) eq 'ARRAY' ? @$filename : ($filename);
- $data = <FH>;
- $self->{'data'} = \$data;
+ foreach my $file (@files) {
+ unless (open FH, $file) {
+ return $self->error("Can't read file '$file': $!");
+ }
- unless (close FH) {
- return $self->error("Can't close file '$filename': $!");
- }
+ $data .= <FH>;
+
+ unless (close FH) {
+ return $self->error("Can't close file '$file': $!");
+ }
+ }
+
+ $self->{'data'} = \$data;
}
return $self->{'data'};
my $output = $translator->translate(
from => "MySQL",
to => "Oracle",
- filename => $file,
+ filename => $file, #or an arrayref of filenames, ie [$file1,$file2,$file3]
) or die $translator->error;
print $output;