Help for this page

Select Code to Download


  1. or download this
    opendir my $d, $dir;
    
  2. or download this
    my @f = sort { -M $b <=> -M $a } readdir $d;
    
  3. or download this
    my @file_list =  sort { -M $b <=> -M $a }
                     grep -f, readdir $dir_handle;
    
  4. or download this
    unlink @f[-0,1] if @f > 20;
    
  5. or download this
    use File::Spec 'catfile';
    
    unlink map catfile($dir, $_), @f[0,1]
      if @file_list > 20;
    
  6. or download this
    use File::Spec 'catfile';
    
    ...
    
    unlink map catfile($dir, $_), @f[0,1]
      if @file_list > 20;