我想写一个简短的 Perl prg,它有 1 个参数(一个 3 位整数)传递给它,并根据它是哪个列表的成员返回相应列表的编号。我怎样才能做到这一点,还有什么方法可以将一系列数字作为元素放入列表中?
::Returns 1,2,3,4 Depending on testNum passed
@gp1= (829,845,851,859,864,867);
@gp2= ("826-828","830-839","843-844","847-850","852-854","860-862","883");
@gp3= ("855-858",861,"863","865");
@gp4= ("877-882",884);
if ( ($ARGV[0]>=822 && $ARGV[0] <=824) || $ARGV[0] is membergp1)
{
return 1
}
if ( $ARGV[0]>=826 && $ARGV[0]<=828 || $ARGV[0] is memebr of group2
return 2
if $ARGV[0] is memebr of group3
return 3
if $ARGV[0] is memebr of group4
return 4