perl Exporter一些神奇写法

use base qw(Exporter);
@JSON::EXPORT = qw(from_json to_json jsonToObj objToJson encode_json decode_json);


[root@wx03 5]# cat Fred.pm 
package Fred;
use Exporter 'import';
@EXPORT = qw(flintstone $var);

sub flintstone{

return 99;
};
our $var="SADA1311";
1;
[root@wx03 5]# cat a1.pl 
use Fred  qw/flintstone $var/;
print $var;
print "\n";

print flintstone;

[root@wx03 5]# perl a1.pl 
SADA1311
99[root@wx03 5]# 


还可以这么玩?

[root@wx03 5]# cat a1.pl 
use Fred  qw/flintstone $var/;
print $var;
print "\n";

print flintstone;

[root@wx03 5]# cat Fred.pm 
package Fred;
use Exporter 'import';
@Fred::EXPORT = qw(flintstone $var);

sub flintstone{

return 99;
};
our $var="SADA1311";
1;
[root@wx03 5]# perl a1.pl 
SADA1311
99[root@wx03 5]# 

posted @ 2016-05-29 14:45  czcb  阅读(119)  评论(0编辑  收藏  举报