是函数原型写的问题吧,

sort LIST 是类似于:  sort  1.. 100
sort BLOCK list 是类似于  sort { $a <=> $b}  @list ,            block 语句
sort SUBNAME  list  是类似于 sort  my_cmy @list ,

sub  my_cmp {
     $a  <=> $b ||  $a cmp $b
}


你的test是要这个3个功能是吧,

一般的sub  ,  test  @list 肯定行,
test {  XXX }  @list  这个也行吧, 可用eval,
test  subname @list 这个难写啊, 也用eval么,

函数原型查下, 估计不要用eval,


2011/11/27 昨夜星尘 <[email protected]>

> sort函数可以使用如下形式:
> sort LIST
> sort BLOCK LIST
> sort SUBNAME LIST
> 但我自己怎么都定义不出这个形式的函数
> sub test(&@) {
> ...
> }
> 只能使用
> test { ... } @var
> 如果使用sub test { ... }
> 那只能使用
> test sub {...},@var
> 怎么都实现不了sort的调用方式
>
> --
> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>
>


-- 
            Yours Sincerely
                    Zeng Hong

-- 
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

回复