X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FParser%2FExcel.pm;h=846095a4ef776b39065c9a6b3f298cb47f3fac43;hb=c0ec0e22d3f0e3852c00daac5ef5763010b410c3;hp=56be8eed10c6992bf91f1b1fc5e2c1ce6de374d5;hpb=935800450f88b0500c4fa7c3b174cd22b5f9eb56;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Parser/Excel.pm b/lib/SQL/Translator/Parser/Excel.pm index 56be8ee..846095a 100644 --- a/lib/SQL/Translator/Parser/Excel.pm +++ b/lib/SQL/Translator/Parser/Excel.pm @@ -29,9 +29,10 @@ and field sizes. True by default. =cut use strict; -use vars qw($DEBUG $VERSION @EXPORT_OK); +use warnings; +our ($DEBUG, @EXPORT_OK); $DEBUG = 0 unless defined $DEBUG; -$VERSION = '1.59'; +our $VERSION = '1.59'; use Spreadsheet::ParseExcel; use Exporter; @@ -97,7 +98,7 @@ sub parse { # # If directed, look at every field's values to guess size and type. # - unless ( + unless ( defined $args->{'scan_fields'} && $args->{'scan_fields'} == 0 ) { @@ -105,12 +106,12 @@ sub parse { for( my $iR = $ws->{'MinRow'} == 0 ? 1 : $ws->{'MinRow'}; - defined $ws->{'MaxRow'} && $iR <= $ws->{'MaxRow'}; + defined $ws->{'MaxRow'} && $iR <= $ws->{'MaxRow'}; $iR++ ) { - for ( + for ( my $iC = $ws->{'MinCol'}; - defined $ws->{'MaxCol'} && $iC <= $ws->{'MaxCol'}; + defined $ws->{'MaxCol'} && $iC <= $ws->{'MaxCol'}; $iC++ ) { my $field = $field_names[ $iC ]; @@ -122,16 +123,16 @@ sub parse { if ( $data =~ /^-?\d+$/ ) { $type = 'integer'; } - elsif ( - $data =~ /^-?[,\d]+\.[\d+]?$/ + elsif ( + $data =~ /^-?[,\d]+\.[\d+]?$/ || - $data =~ /^-?[,\d]+?\.\d+$/ + $data =~ /^-?[,\d]+?\.\d+$/ || - $data =~ /^-?\.\d+$/ + $data =~ /^-?\.\d+$/ ) { $type = 'float'; - my ( $w, $d ) = - map { s/,//g; length $_ || 1 } + my ( $w, $d ) = + map { s/,//g; length $_ || 1 } split( /\./, $data ) ; $size = [ $w + $d, $d ]; @@ -154,8 +155,8 @@ sub parse { for my $field ( keys %field_info ) { my $size = $field_info{ $field }{'size'} || [ 1 ]; - my $data_type = - $field_info{ $field }{'char'} ? 'char' : + my $data_type = + $field_info{ $field }{'char'} ? 'char' : $field_info{ $field }{'float'} ? 'float' : $field_info{ $field }{'integer'} ? 'integer' : 'char'; @@ -173,7 +174,6 @@ sub parse { return 1; } -# ------------------------------------------------------------------- sub ET_to_ST { my $et = shift; $ET_to_ST{$et} || $ET_to_ST{'Text'};