print "I'm an artist, a performance artist\n" if $self->name eq 'Van'; } ...
perl -e 'while(<>){chomp;if(/^>/){$id=$_;}else{$seq=$_;$hash{$id}=$seq;}}foreach$b(keys%hash){printqq{$b\n$hash{$b}\n}}' mapper.fa > new.fa 15.根据id提取想要的fasta文件(来自CJ的perl oneliner) # 批量提取fasta perl -lne 'if($switch){if(/^>/){$flag=0;m/^>?
if ($fred =~ /^[A-Z_]\w*$/i) { #什么也不做 } else { print "The value of \$fred doesn't look like a Perl identifier name.\n"; } unless 和 else 一起 unless ($mon =~ /^Feb/) { print "This month has at least thirty days.\n"; } else { print "Do you see what's...
hello world hello world $ echo "A B C" | perl -lane 'print $F[0]' A image.png 其他示例 https://github.com/aleksandarstojkovski/Usefull-Perl-Oneliners Command:perl-ne'print/(REGEX_HERE)/?"match":"no-match"' Example:echo"ABC123"|perl-ne'print/ABC123/?"match":"no-match"' Outpu...
unless控制结构:和if相对 在条件为假时想要运行代码块,就用unless否则就用if: unless(judge){ } 伴随unless的else子句: unless(){ } else { } until控制结构: until($j > $i) { $j *= 2; } until在条件为假时重复执行,直到为真为止,和while相对。
对于Perl 没有一个很好的集成开发环境的话,perl还有一个很好的工具: 叫做Perl one line 这个Perl one line 可以很好地代替我们的一些函数学习以及脚本测试的工作。 Perl one line 夯实基础 首先明确 perl 的一个规则 在perl 里面双引号可以用qq{}qq##还有qq()代替 ...
if($line eq “\n”){ print “That was just a blank line!\n”; }else{ print “That line of input was: $line”; } 1. 2. 3. 4. 5. 6. 实际上,通常你不需要保留换行符,因此需要chomp 来去掉它。 7.chomp 操作对变量起作用,而此变量含有字符串。如果字符串结尾有换行符,chomp ...
如:$some_other="I dream of betty rubble"; if($some_other=~/\brub/){print "配上了\n";}else{print "没配上\n";} 6.模式串中的内插 my $what=XX; while(<>){ if(/^($what)/){#($what)模式串中的内插; \^为锚位 print "we saw $what is the beginning of this input\n";}#...
unless(condition){command;}#这个结构等效于if(!(condition)){command},此外还有unlesselse结构,如下所示:unless(condition){command1}else{command2}#其相当于:if(condition){command2}else{command1} ②elsif控制结构 无论是if else还是unless else都只能判断一个条件表达式的真假,如果需要结合多个条件表达式的真假...
LINE:while(<>) { foreach (split) { last LINE if /__END__/; # 如果发现有'__END__'的标记,则跳出至标签为LINE的循环 } } 条件操作符 "?:" 逻辑运算发 "and && or ||" 短路操作符 逻辑运算符同C一样有短路效应,但求值结果不是简单的布尔值,而是最后运算那部分表达式的值 my lastname=last...