kevind0718 has asked for the wisdom of the Perl Monks concerning the following question:
sub maxFileDate { my ( $filePrefix_In, @entries_In, $yr_ref, $mth_ref, $dt_ref ); ( $filePrefix_In, @entries_In, $yr_ref, $mth_ref, $dt_ref ) = @_ ; my $entry; my @fields; my @fileName; print "fileName Prefix: " . $filePrefix_In . "\n" ; ##print Dumper @entries_In ; my $maxdate = 20000101; foreach $entry (@entries_In) { ##print "$entry \n "; chomp $entry; @fields = split /\s+/, $entry; if ( $fields[0] =~ m/^-/) { # ** ** ** ** #this a file entry if ($fields[-1] =~ m/^$filePrefix_In/) { @fileName = split /\.|_/ , $fields[-1]; print Dumper @fileName ; print "file name: " . $fields[-1] . " date part: " . $ +fileName[4]. $fileName[5]. $fileName[6]. "\n"; if ( ('20'. $fileName[4]. $fileName[5]. $fileName[6]) > $ +maxdate ) { $maxdate = ('20'. $fileName[4]. $fileName[5]. $fileNa +me[6]) ; $$yr_ref = $fileName[4]; $$mth_ref = $fileName[5]; $$dt_ref = $fileName[6]; } } ##file name like } ##file entries } ## for each entry print "yr " . $yr_ref . "\n" ; print "mth". $mth_ref . "\n" ; print "dt " . $dt_ref . "\n" ; print "yr " . $$yr_ref . "\n" ; print "mth". $$mth_ref . "\n" ; print "dt " . $$dt_ref . "\n" ; ##$maxdate; } # maxFileDate
if ( !defined( $datein ) ) { maxFileDate('WSB826TB', @entries, \$yr, \$mth, \$dt ); } # no date passed in else { $datea = $datein; } print "\nDownload WSB826TB for date: " . $yr. $mth. $dt . "\n";
C:\HFAccess\devPostgresql>perl -w xxx_ftpgetTest.pl xxx_ftp.prop Properties File: xxx_ftp.prop. Properties FTPServer = ftp.xxx.ml.com RemoteDirectory = /outgoing User Id = mysecretid LocalServer = LocalDirectory = C:\HFAccess\xxxx GPG_HomeDirectory = Q:\Downloads\gnupg\keys Remote Directory: /outgoing fileName Prefix: WSB826TB $VAR1 = 'WSB826TB'; $VAR2 = 'CST238PO'; $VAR3 = 'CSV'; $VAR4 = 'asc'; $VAR5 = '09'; $VAR6 = '04'; $VAR7 = '21'; $VAR8 = '01'; $VAR9 = '10'; file name: WSB826TB.CST238PO.CSV.asc.09.04.21_01.10 date part: 09042 +1 $VAR1 = 'WSB826TB'; $VAR2 = 'CST238PO'; $VAR3 = 'CSV'; $VAR4 = 'asc'; $VAR5 = '09'; $VAR6 = '04'; $VAR7 = '22'; $VAR8 = '00'; $VAR9 = '54'; file name: WSB826TB.CST238PO.CSV.asc.09.04.22_00.54 date part: 09042 +2 $VAR1 = 'WSB826TB'; $VAR2 = 'CST238PO'; $VAR3 = 'CSV'; $VAR4 = 'asc'; $VAR5 = '09'; $VAR6 = '04'; $VAR7 = '23'; $VAR8 = '02'; $VAR9 = '43'; file name: WSB826TB.CST238PO.CSV.asc.09.04.23_02.43 date part: 09042 +3 $VAR1 = 'WSB826TB'; $VAR2 = 'CST238PO'; $VAR3 = 'CSV'; $VAR4 = 'asc'; $VAR5 = '09'; $VAR6 = '04'; $VAR7 = '24'; $VAR8 = '01'; $VAR9 = '33'; file name: WSB826TB.CST238PO.CSV.asc.09.04.24_01.33 date part: 09042 +4 $VAR1 = 'WSB826TB'; $VAR2 = 'CST238PO'; $VAR3 = 'CSV'; $VAR4 = 'asc'; $VAR5 = '09'; $VAR6 = '04'; $VAR7 = '25'; $VAR8 = '00'; $VAR9 = '26'; file name: WSB826TB.CST238PO.CSV.asc.09.04.25_00.26 date part: 09042 +5 yr SCALAR(0x1ae256c) mthSCALAR(0x1ae2578) dt SCALAR(0x1ae2584) yr 09 mth04 dt 25 Use of uninitialized value in concatenation (.) or string at xxx_ftpge +tTest.pl line 153. Use of uninitialized value in concatenation (.) or string at xxx_ftpge +tTest.pl line 153. Use of uninitialized value in concatenation (.) or string at xxx_ftpge +tTest.pl line 153. Download WSB826TB for date: C:\HFAccess\devPostgresql>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: simple reference
by moritz (Cardinal) on Apr 27, 2009 at 21:42 UTC | |
|
Re: simple reference
by lostjimmy (Chaplain) on Apr 27, 2009 at 21:41 UTC | |
|
Re: simple reference
by shmem (Chancellor) on Apr 27, 2009 at 21:46 UTC |