if (-f $Db_file.".nhr")
摘要:-f运算符测试其操作数是否是常规文件,而不是目录,符号链接或其他特殊文件。 所有以-开头的运算符都称为文件测试运算符,通常也可以在shell脚本语言中找到。它们是一元运算符(仅占一个操作数),如!或~是一元运算符。 -e 该“文件名”是否存在-f 该“文件名”是否为文件-d 该“文件名”是否为目录-
阅读全文
翻译my $Queue_para=(defined $Queue)?"-queue $Queue":'';
摘要:#!/usr/bin/perl my $Queue_para=(defined $Queue)?"-queue $Queue":''; my $Q="";my $Q1;if (defined $Q){ $Q1="-queue $Q"; print "$Q1\n";}else{ $Q1="\n"; p
阅读全文
undef|defined
摘要:1.undef undef是perl中变量未初始化时的默认值。当这个未初始化的变量被当做整型来使用时,那么undef就是0;当这个变量被当做字符串来使用时,那么undef就是空字符串。所以当在perl中使用一个未经过初始化的变量时,程序的运行是没有问题的。 例如: $sum += 1; #该语句第一
阅读全文
glob
摘要:perl中通过文件操作符glob提供相当于shell中的指定多个文件的“通配符”语法功能,文件操作符glob将返回与所指定的glob文件模式相匹配的所有文件的list。 glob的用法--读取一个目录下的所有文件1. 比如要读取/home/globtest目录中的所有文件,可以这样写:@plFile
阅读全文
unless 的简写模式
摘要:#!/usr/bin/perl my $a='a'; print "right" unless ($a != 'a');
阅读全文
qw
摘要:定义和用法 qw()是用来指定了很多小单引号的句字是一个快速的方法。例如,qw(foo bar baz) 相当于 ('foo', 'bar', 'baz')。一些程序员认为,使用qw使Perl脚本更容易阅读。实际上,你可以使用任何分隔符,而不仅仅是括号组。 简单地,可以使用qw()准备一个数组,如以
阅读全文
open 管道用法|Getopt::Long
摘要:#!/usr/bin/perl use strict; use warnings; use Getopt::Long; my ($number,$in,$out); GetOptions( "number:i"=>\$number, "in:s"=>\$in, "out:s"=>\$out ); #my $all = $number +1;print $all; ...
阅读全文
push 空内容push入数组会占位
摘要:1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 6 my $new = (0 ==1)?233:'';my @arr; 7 my $new_1 = (1==1)?233:''; 8 push @arr,$new_1;push @arr,$new;push @arr,'123456'; 9 my $line = join...
阅读全文
在大文件中照小文件对应项的剩余部分并输出
摘要:1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 6 #####input##### 7 my $all = $ARGV[0]; my $part_file = $ARGV[1]; 8 9 10 11 #####mian##### 12 13 my $all_in = &store($all); 14 my $p...
阅读全文
用hash存数组|得地址|取地址
摘要:key: hash的标准形式是:$hash{$key}=value; 取地址:$hash_ad = \%hash; 解地址: 整个hash:%new_hash = %{$hash_ad};变量形式相对应; 单个hash元素:$single = $hash_ad->{$key};这是由$hash{$k
阅读全文
index|substr
摘要:1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 6 $_ = 'duwanxkm,c.,df;oq123@#!@%$#^'; 7 my $d ='d';my $o = 'o';my $where =index($_,$o);print "$where\n"; 8 $where =index($_,$d,7);print ...
阅读全文
关于目录的操作|*|<>|opendir |readdir|unlink|find2perl|rename|readlink|oct()|utime
摘要:1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 6 foreach my $arg(@ARGV) 7 { 8 print "one is $arg\n"; 9 } 10 11 # perl t.pl *.txt 12 # one is 1.txt 13 # one is 2.txt 14 15 my @al...
阅读全文
文件操作符|-e|-M|-s|-A|_|-r -w $filename|stat|localtime|&|>>|<<
摘要:TTY:终端是一种字符型设备,它有多种类型,通常使用tty 来简称各种类型的终端设备
阅读全文
unless|until|LABEL|{}|last|next|redo| || |//|i++|++i
摘要:1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 6 $_ = 'oireqo````'; 7 8 unless($_ =~ /^a/m){print "no match to a\n"} 9 10 #no match to a 11 12 if(!($_ =~ /^a/m)){print ...
阅读全文
计算蛋白质一致率
摘要:1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 6 my $input = $ARGV[0];my $name = $ARGV[1];my $start = $ARGV[2];my $cut_start=$ARGV[3];my $cut_end=$ARGV[4]; 7 8 my $all_start=$ARGV[5]...
阅读全文
字符串与数字之间的转换
摘要:1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 6 my $number = 1;$number =~/(\w*)/;print "$1"; 7 $number++;print "$number\n";
阅读全文
gff文件提取cds
摘要:1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 ########input######## 6 7 my $gff = $ARGV[0];my $cut = &cut($gff);my %cut = %$cut; 8 9 my ($gene_number,$gene_id,$gene_name) = ($ARGV[...
阅读全文
s///|s()()i|/i|/g|\U|\u|\L|\l|\U\l|split|join|匹配到hash|匹配到变量|`date`|$^I
摘要:问题: 1 cat 1.txt |perl test.pl 后并无备份文件1.txt.bak?
阅读全文
/^/m|/$/m|\b|\B|$&|$`|$'|变量捕获|()?|(?:pattern)|(?<LABEL>PATTERN)|$+{LABEL}|(|)|\g{LABEL}
摘要:1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 6 $_=' 7 8 $$ oinn &&& 9 ninq kdownc 10 aninp 11 kkkk'; 12 13 if (/(.*)k\Z/){print "$1\n";}else{print "no match\n";} 14 ...
阅读全文
$|^|\z|\Z|/a|/l
摘要:1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 6 foreach() 7 { 8 if (/(\w*)/a){print "$1\n";}else{print "no match\n";} 9 } 10 11 #11111111111111111111111111111111111 12 #nciuwbuf...
阅读全文