方法::签名,模块中的函数输出顺序

时间:2012-01-20 06:58:13

标签: perl sequence func

我正在编写自己的模块,其中我定义了三个函数:

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 :

但它们并不是完全随机的,因为每次运行脚本时它都会有这样的确切序列。

1 个答案:

答案 0 :(得分:2)

您可能想通过执行以下操作来检查代码管理器如何破坏您的宠儿:

use Data::Dumper qw<Dumper>;

$Data::Dumper::Deparse = 1;

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

也许这可能会给你一个线索。