按时间查找文件

按时间查找文件

标题如上: 下面是源代码.
帮我看看,那里出了问题.

#! /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);
太长了点。呵呵
#! /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);
怎么还有笑脸啊。。第一个笑脸是)  第二笑脸是 第三个笑脸是  第四个笑脸是) 第五个笑脸是)
疯了 疯了