English 中文(简体)
登记所有档案的更正
原标题:Perl script to list all the files

I have a website where some of the downloadale files are stored. say the website contains files like

GTP-UGP-LATEST-5.3.0.123.iso
GTP-UGP-LATEST-5.3.0.127.iso
GTP-UGP-LATEST-5.3.0.132.iso
GTP-UGP-LATEST-5.3.0.136.iso

PRE-UGP-LATEST-5.3.0.124.iso
PRE-UGP-LATEST-5.3.0.126.iso
PRE-UGP-LATEST-5.3.0.127.iso
PRE-UGP-LATEST-5.3.0.130.iso

这些档案的数量将随着日复一日地增加,其编号为自动编号。

我的最终目标是每天管理文字(cronjob),以检查是否有任何新档案,如果是下载所增加的所有新档案。

我的逻辑是,从GTP*(第5.3.0.123段)到(530123页)查阅所有档案的版本,然后与以前下载的版本相比,后者储存在当地档案中。 如果能够匹配,我们用从全球优惠制开始的最大版本下载文件。

And we do similary with file starting with PRE*

穷人经常表达,请帮助我。

请让我知道,将所有档案都列入一个链接,然后将其写到当地档案中。 如果我知道这么多,我就认为我可以从那里来。

最佳回答

<>上>: 我将做以下工作(测试):

#!/usr/bin/env perl

use Data::Dumper qw(Dumper);
use File::Glob  :glob ;

sub by_version {
  my $v_a = $a;
  my $v_b = $b;
  $v_a =~ s/[^d.]//g;
  $v_b =~ s/[^d.]//g;
  my @version_a = split(/./, $v_a);
  my @version_b = split(/./, $v_b);

  for (my $i = 0; $i < scalar(@version_a); $i++) {
    my $comp = $version_a[$i] <=> $version_b[$i];
    return $comp if ($comp != 0);
  }

  return 0;
}

my @files = bsd_glob( GTP-UGP-LATEST-*.iso );
my @sorted_files = sort by_version @files;
print Dumper(@sorted_files);
问题回答

或者,你只能从下载目录中提一下,因为你只想到新的目录。





相关问题
How to upload and download file from a server using C#

I am developing a webpage in that the user can download their Resume for Edit. So I have a link to download the article. I use the following code for download. DataTable dt = user.getUserDetails(2); ...

Detecting PDF Download

I have recently added functionality for generating pdf reports to a web application. However the reports can be quite large and take some time to show the pdf download dialog. I want to show a spinner ...

Writing file to users giving sporadic error in IE

I have a very interesting issue with only specific IE implementations. I have an ASPX page that is used to write files down to the user, as part of the process the page uses the following code to ...

PHP - List of Excel files to download from Intranet Site?

I have a intranet site running PHP 5 that needs to list a folder containing only Excel files. Ideally the user needs to be able to input some search criteria (ie date) and the files would be filtered ...

Determine total size of SVN directory/trunk

Is there a way to count/calculate the total size of a svn directory if you were to checkout a revision? I have limited internet downloads so I need to know how big something is before I go and ...

Scala and html: download an image (*.jpg, etc) to Hard drive

I ve got a Scala program that downloads and parses html. I got the links to the image files form the html, Now I need to transfer those images to my hard drive. I m wondering what the best Scala ...

Downloading file with wxHTTP?

Im really stumped. Im using the wxHTTP class in wxWidgets to try and download two files. The first request succeeds but the second one fails when wxHTTP->GetInputStream is called. Between downloads, ...

热门标签