String 使用perl搜索字符串中的未知子字符串

String 使用perl搜索字符串中的未知子字符串,string,perl,String,Perl,我正在尝试从网站下载一个文件。 但我只想在文件版本比我拥有的同一个文件更新的情况下下载 文件名为CTP-Latest5.0.37.iso 我需要检查文件名中的字符串“37” 因此,如果数字37大于我已经拥有的版本,那么只有我下载 下载文件后,我希望存储字符串“37”是一个文件,以便下次运行perl代码检查版本时可以读取它 这是我的代码,我正在尝试 #!/usr/bin/perl use LWP::Simple; #my $version =37;//this whole line is com

我正在尝试从网站下载一个文件。 但我只想在文件版本比我拥有的同一个文件更新的情况下下载

文件名为CTP-Latest5.0.37.iso

我需要检查文件名中的字符串“37”

因此,如果数字37大于我已经拥有的版本,那么只有我下载

下载文件后,我希望存储字符串“37”是一个文件,以便下次运行perl代码检查版本时可以读取它

这是我的代码,我正在尝试

#!/usr/bin/perl
use LWP::Simple;
 #my $version =37;//this whole line is commented
Open file version.txt and get the version number(say 37)and store it in $version    


$pageURL="http://www.google.comisos/psfsS5.3/LATIMGODCVP/"; 

$simplePage=get($pageURL);

Now $simplePage has the substring  "CTP-LATEST-5.3.0.(some_version_number).iso" 

I need to get that "some_version_number". HOW ?


if(some_version_numner > $version)

{


#-- fetch the zip and save it as perlhowto.zip
my $status = getstore("http://www.google.com/isos/psfsS5.3/LATIMGODCVP/CVP-LATEST-5.3.0."$version".iso", "CTP-Latest5.3.0.$version.iso");

if ( is_success($status) )
{
 print "file downloaded correctly\n";

 Store the "some_version_number in file version.txt (for next time use)

}
else
{
 print "error downloading file: $status\n";
 }

}
我希望所有的代码都是清晰的。version.txt只存储了一个任意数字的字符串(例如37、45或89等)

有人能帮我完成剩下的代码吗?

应该完成


如果
某些版本号
仅为数字,则可以执行以下操作:

if ($simplePage =~ /CTP-LATEST-5\.3\.0\.\((\d*)\)\.iso/)
{
    $some_version_number = $1;
}
if ($simplePage =~ /CTP-LATEST-5\.3\.0\.\((.*)\)\.iso/)
{
    $some_version_number = $1;
}
如果在
simplePage
中不仅有数字,而且没有其他括号,则可以执行以下操作:

if ($simplePage =~ /CTP-LATEST-5\.3\.0\.\((\d*)\)\.iso/)
{
    $some_version_number = $1;
}
if ($simplePage =~ /CTP-LATEST-5\.3\.0\.\((.*)\)\.iso/)
{
    $some_version_number = $1;
}

嘿,伊戈尔,在网站上还有其他扩展名为.iso的文件,但我只需要一个文件“CTP-LATEST-5.3.0”。mac,我相应地编辑了答案。我建议你阅读链接上的材料,并写出你需要的确切逻辑。这对我不起作用,我试着撬$some\u version\u number,但它不打印任何内容。这对我不起作用,我试着撬$some\u version\u number,但它不打印任何内容。我想让它打印5.3.0中的某个版本号。“某个版本号”.iso。这个答案中的代码有语法错误。if()需要一个块。Perl不是C:-)