2012年5月17日星期四

[PerlChina] more than one way in perl

Hi, perlers,

Supposing I have a hash reference in hand, the effect of the following two statements

$hash1_ref = &subroutine1( $hash0_ref, 'parameter1' );
$hash2_ref = &subroutine1( $hash1_ref, 'parameter2' );

will save elements in $hash0_ref, stafisfying both parameter1 and parameter2, into $hash2_ref.

I try to do this by following one statement, but I failed.

$hash_ref2 = &subroutine1( &subroutine1( $hash0_ref, 'parameter1'), 'paratemter2') ;

any help? THANKS in advance

==================================================
下面的语句可以得到$hash0_ref中同时满足parameter1 和parameter2的结果,并放到$hash2_ref中。
$hash1_ref = &subroutine1( $hash0_ref, 'parameter1' );
$hash2_ref = &subroutine1( $hash1_ref, 'parameter2' );


现在我换一种写法,理论上,可以得到相同的结果,但报错了。请高高手指导。谢谢

$hash_ref2 = &subroutine1( &subroutine1( $hash0_ref, 'parameter1'), 'paratemter2') ;




Haiyan Lin

没有评论: