首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

请问一个switch语句的有关问题

2012-03-31 
请教一个switch语句的问题Perl code swith($line){case $line~ m/taxid:9606\(Homo sapiens\)\ttaxid\:96

请教一个switch语句的问题

Perl code
 swith($line)    {        case $line=~ m/taxid:9606\(Homo sapiens\)\ttaxid\:9606\(Homo sapiens\)/            {                print M_PROCESSED_human $line;            }        case  $line=~ m/taxid:10090\(Mus musculus\)\ttaxid\:10090\(Mus musculus\)/            {                print M_PROCESSED_mouse $line;            }        else            {                next;            }


[解决办法]
难道LZ的编辑器没有语法高亮?
[解决办法]
[code=Perl] use Switch;

switch ($val) {
case 1 { print "number 1 " }
case "a " { print "string a " }
case [1..10,42] { print "number in list " }
case (\@array) { print "number in list " }
case /\w+/ { print "pattern " }
case qr/\w+/ { print "pattern " }
case (\%hash) { print "entry in hash " }
case (\&sub) { print "arg to subroutine " }
else { print "previous case not true " }
}[/code]


[解决办法]
http://search.cpan.org/~rgarcia/Switch-2.16/Switch.pm

热点排行