开发者

difference between perl version

开发者 https://www.devze.com 2023-03-11 00:55 出处:网络
In perl 5.8.8 I use next con开发者_运维问答struction: Package Common; BEGIN { require Exporter; use vars qw( @EXPORT );

In perl 5.8.8 I use next con开发者_运维问答struction:

Package Common;

BEGIN
{
    require Exporter;
    use vars qw( @EXPORT );
    @EXPORT=qw( test )
}

sub test {
   my ( $self ) = shift
}

1;

Package My;
use Common;
sub test1 {
  print $self -> test();
}

1;

It works. But in perl 5.10.0 it does not work. Why?


First of all, USUW ( use strict; use warnings; ).

And when you do that, you'll see that $self is not defined in the scope of (what should be) package My; or My::test1. Also Package is obviously treated as a bareword without strict 'subs', which does not mean the same thing as package with a lowercase 'p'.

I'm dubious that this works in 5.8. But I no longer have any sub-5.12 environments to check.

0

精彩评论

暂无评论...
验证码 换一张
取 消