title: Perl: Fastest way to find files older than X number of minutes, sorted oldest to newest
body: <p>im trying to check if there is a file (i dont care about folders) that older than X minuts. unfortunatly i can;t tell where is my bug on this code.
  i will appriciate any help :)</p>
  
  <p><strong>1. Find the files older than X number of minute</strong></p>
  
  <pre><code>#!/usr/bin/perl 
  
  my $maindir = "C:\\Users\\Dor\\Desktop\\aba";
  my $minutesold = 60;
  my $now = time;
  my $filedisc;
  
  # Declare arrays
  my @xmlfiles;
  my @qulfiedfiles; 
  
  # Declare a Dictionary
  my %filedisc;
  
  opendir(my $dh, $maindir) or die "opendir($maindir): $!";
  
   # Read all the files
   while (my $de = readdir($dh)) 
   {
      # get the Full path of the file
      my $f = $maindir . $de;
  
      if ( -f $f )
      {
  
          push (@xmlfiles, $f); 
  
      }
  }
      closedir($dh);
  
  
   # For every file in directory
   for my $file (@xmlfiles) {
  
      # Get stats about a file
      my @stats = stat($file);
  
      # If time stamp is older than minutes provided
      if ($stats[9] &gt;= ($now - (( $minutesold * 60) ))){
  
         # Put the File and Time stamp in the dictionary
         print($stats[9] ."          .|           "  .$file ."\n\n");
  
      }
  
      #print($now ."\n")
      #print($now - ( $minutesold * 60) ."\n"); 
   }
  </code></pre>