2012-01-20 30 views
1

我寫我自己的模塊,在我所定義的三個功能:方法::簽名,功能輸出的順序模塊

package YUCO::Test; 

use 5.008008; 
use strict; 
use warnings; 

require Exporter; 
use AutoLoader qw(AUTOLOAD); 
use Method::Signatures; 

our @ISA = qw(Exporter); 
our %EXPORT_TAGS = ('all' => [ qw() ]); 
our @EXPORT_OK = (@{ $EXPORT_TAGS{'all'} }); 
our @EXPORT = qw(Test1 Test2 Test3); 
our $VERSION = '0.01'; 

#----------------------------------------------------- 
func Test1(Str $a='') 
{ 
     print ' ok from Test1, and a is : '.$a."\n"; 
} 

#----------------------------------------------------- 
func Test2(Str $a='') 
{ 
     print ' ok from Test2, and a is : '.$a."\n"; 
} 

#----------------------------------------------------- 
func Test3(Str $a='') 
{ 
     print ' ok from Test3, and a is : '.$a."\n"; 
} 

#----------------------------------------------------- 

1; 
__END__ 

,然後當我做了一個測試程序與這些行:

#!/usr/bin/perl -w 

use strict; 
use warnings; 

use YUCO::Test qw(Test1 Test2 Test3); 

Test1('a ar'); 
Test2('b lo'); 
Test3('..c..'); 

Test1(); 
Test2(); 
Test3(); 

它具有這樣的輸出,它具有一些奇怪/隨機輸出序列:

ok from Test2, and a is : b lo 
ok from Test3, and a is : ..c.. 
ok from Test2, and a is : 
ok from Test3, and a is : 
ok from Test1, and a is : a ar 
ok from Test1, and a is : 

但它們並不完全隨機,因爲每次運行腳本時它都會有這樣的確切序列。

回答

2

你可能要檢查代碼如何壓榨機是通過執行以下操作重整你的寵兒:

use Data::Dumper qw<Dumper>; 

$Data::Dumper::Deparse = 1; 

say Dumper(\&YUCO::Test::Test1); 

或許可能給你一個線索。