LINUX.ORG.RU

История изменений

Исправление DRVTiny, (текущая версия) :

И даже так:

use strict;
use constant R=>"hello\n";
no strict "refs";
my $x="R"; *{__PACKAGE__."::$x"} = sub { "bye\n" };
my $l = \&{$x};
print ref($l)." => ".$l->()

Output:

Constant subroutine main::R redefined at -e line 1.
Prototype mismatch: sub main::R () vs none at -e line 1.
CODE => bye

Охренеть, дайте два...

$ perl -e 'use strict; use 5.16.1; use constant R=>"hello\n"; no strict "refs"; my $x="R"; *{__PACKAGE__."::$x"}=sub () { "bye\n" }; print R; my $l=\&{$x}; print ref($l)." => ".$l->()'
Constant subroutine main::R redefined at -e line 1.
hello
CODE => bye

Исходная версия DRVTiny, :

И даже так:

use strict;
use constant R=>"hello\n";
no strict "refs";
my $x="R"; *{__PACKAGE__."::$x"} = sub { "bye\n" };
my $l = \&{$x};
print ref($l)." => ".$l->()

Output:

Constant subroutine main::R redefined at -e line 1.
Prototype mismatch: sub main::R () vs none at -e line 1.
CODE => bye