6: Probe: Pr000034.1 而xx是为Pr000029.1等除去0的整数,所以第一步先处理probe.txt得到整数的文件uid.txt 代码如下: #!/usr/bin/perl open(RH,"probe.txt") or die "cannot read probe.txt:$!"; my @lines = ; chomp @lines; close RH or die "cannot close probe.txt:$!"; open(WH,">uid.txt") or die "cannot write uid.txt:$!"; for(my $i = 1; $i < @lines; $i += 2){ $lines[$i] =~ /.*Pr0*(d+).d/; print WH "$1
"; }
close WH or die "cannot close uid.txt:$!";
注意正则的匹配,经过处理,得到uid.txt。中保存有uid的整数值,下面就要下载该文件了 代码如下: #!/usr/bin/perl open(RH,"uid.txt") or die "can not open uid.txt:$!"; my @lines = ; chomp @lines; close RH or die "cannot close uid.txt:$!"; for(my $i = $#lines; $i > -1; $i --){ my $url = "[$i]"; system("wget -O pr_htmls/$i.html '$url'"); } print "done
";
#!/usr/bin/perl #use strict; #先把文件读进来,参数1为读取的文件名 my $in = $ARGV[0]; my $id,$seq1,$seq2,$geneid,$pub; die "没有读入的文件" if(!defined($in)); open(RH,$in) or die "Can not read $in"; my @lines = ; close RH or die "can not close $in:$!"; #读取第一个字段,Prxxxxx.x $lines[49] =~ /(Prd+.d)$/; $id = $1; for(my $i = 50; $i < @lines; $i ++){ if($lines[$i] =~ /