- 论坛徽章:
- 0
|
标题如上: 下面是源代码.
帮我看看,那里出了问题.
#! /usr/bin/env perl -w
use File::stat;
use time::localtime;
use Time::Local;
use POSIX 'strftime';
# get directory all information and format date output.
print "Which directory?";
chomp(my $dir = <STDIN> ;
if ($dir =~/^\s*$/){
chdir or die "Can't chdir to your home directory: $!";
}
else {
chdir $dir or die "Can't chdir to '$dir' !";
}
opendir FM,$dir or die "Can't opendir dot !";
foreach $files(sort readdir FM){
$sb = stat ($files);
$timeby = scalar localtime $sb->mtime;
my $datetime = $timeby;
my %month;
@month{ qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/ } = 0..11;
my (undef,$month, $day, $h, $m, $s, $year) = split /\W+/, $datetime;
my $time = timelocal($s,$m,$h,$day,$month{$month},$year);
$formattime = strftime "%Y-%m-%d %H:%M:%S", localtime($time);
print $formattime,"\t","$files","\t",$sb->size,"\n";
open (LOGF,">>mytest.txt" || die "$!";
print LOGF $formattime,"\n";
close(LOGF);
}
open (LOGFILE,"mytest.txt" or die "$!";
@line = <LOGFILE>;
$input = <STDIN>;
foreach my $openlog(@line){
if ($input eq $openlog){
print $openlog,"$files";
}
}
closedir (FM); |
|