[ale] Quick Perl Q

Jonathan Rickman jdr at xcorps.net
Tue Nov 23 15:57:28 EST 2004


-------------------------
#!/usr/bin/perl -w

use strict ;
use POSIX ;
use File::Copy ;
use File::Basename ;
use File::stat ;


chdir "/vm1/share/users/cl"
   or die "BZZZT $!\n" ;

for my $file (<*.EMB>)
  { my ($name,$path,$suffix) = fileparse($file,"\.EMB") ;
    my $mod = (stat $file)[9];
    my $datestamp = strftime("-%Y%m%d-%H%M%S",localtime($mod)) ;
    copy $file,"/vm1/share/users/cl/$name$datestamp$suffix"
      or warn "Cannot copy $file $!\n" ;
  }
--------------------------

Perl gurus,

I am having trouble with the admittedly ugly script above. I am attempting
to append the date modified to all files in a particular directory. All goes
well, except my date modified is getting screwed up (during formatting I
suspect). I end up with the start of the Unix epoch as opposed to the mod
date. Does someone have a more elegant script that I can use or a pointer on
how to fix this one?

Thanks

--
Jonathan 



More information about the Ale mailing list