srianju has asked for the wisdom of the Perl Monks concerning the following question:
If I commented out "Use Strict",then it gives below message but files are moving not by sorted time stampC:\PERL\bin>perl.exe "c:\1file@atime.pl" -e Global symbol "@sorted" requires explicit package name at c:\1file@ati +me.pl line 17. Global symbol "@sorted" requires explicit package name at c:\1file@ati +me.pl line 26. Global symbol "$xmlfile" requires explicit package name at c:\1file@at +ime.pl lin e 30. Global symbol "@sorted" requires explicit package name at c:\1file@ati +me.pl line 30. Global symbol "$xmlfile" requires explicit package name at c:\1file@at +ime.pl lin e 31. Global symbol "$xmlfile" requires explicit package name at c:\1file@at +ime.pl lin e 35. Execution of c:\1file@atime.pl aborted due to compilation errors.
Here is my scriptC:\PERL\bin>perl.exe "c:\1file@atime.pl" -e Use of uninitialized value in numeric comparison (<=>) at c:\1file@ati +me.pl line 17. Use of uninitialized value in numeric comparison (<=>) at c:\1file@ati +me.pl line 17. File Name: ebert_conc.con moved to FTP - 30 mins for next upload. File Name: ebert.xyz moved to FTP - 30 min for next upload.
I have tried couple other ways but not successful and sure where I am doing wrong.I am using perl version 5.8.8. Any help would be appreciated. Regards, Sree#!/usr/bin/perl use warnings; use strict; use File::Copy; my $srcdir = "\\\\windowsservername\\directory\\Subdirectory\\"; my $dest = "C:\\Documents and Settings\\"; for (;;) { opendir(DIR, $srcdir) or die "Can't open $srcdir: $!"; my @files = grep {!/^\.+$/} readdir(DIR); @sorted = reverse(sort{ -M $a <=> -M $b #( $m{$a} ||= -M $a ) <=> # ( $m{$b} ||= -M $b ) } @files); close(DIR); if (!@sorted) { print "Files have been ended.\n\n"; last; } $xmlfile = $sorted[0]; my $old = "$srcdir/$xmlfile"; move($old, $dest) or die "Move $old -> $dest failed: $!"; print "File Name: $xmlfile moved to Fileshare - 30 mins for next u +pload.\n\n"; sleep 1800; # 30 Minutes }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Sort files by oldest timestamp
by moritz (Cardinal) on May 06, 2009 at 06:21 UTC | |
Re: Sort files by oldest timestamp
by ig (Vicar) on May 06, 2009 at 10:36 UTC | |
Re: Sort files by oldest timestamp
by codeacrobat (Chaplain) on May 06, 2009 at 05:54 UTC | |
by pelagic (Priest) on Oct 29, 2009 at 15:31 UTC | |
Re: Sort files by oldest timestamp
by Marshall (Canon) on May 06, 2009 at 07:29 UTC | |
by Anonymous Monk on May 07, 2009 at 05:40 UTC |