Thread Coderef auf unbekannt (13 answers)
Opened by Raubtier at 2015-02-20 15:51

pq
 2015-02-21 00:12
#179809 #179809
User since
2003-08-04
12208 Artikel
Admin1
[Homepage]
user image
das interessante finde ich, dass das wohl schon zur compile-time passiert.
Code (perl): (dl )
1
2
3
4
my $test = $main::{subname} // 'undef';
say "subname: $test";
__END__
subname: undef


Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
my $test = $main::{subname} // 'undef';
say "subname: $test";

my $subref = \&subname;

$test = $main::{subname} // 'undef';
say "subname: $test";
__END__
subname: *main::subname
subname: *main::subname


wogegen das hier:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
my $test = $main::{subname} // 'undef';
say "subname: $test";

my $name = "subname";
my $subref = \&{$name};

$test = $main::{subname} // 'undef';
say "subname: $test";
__END__
subname: undef
subname: *main::subname

zur runtime passiert.
Last edited: 2015-02-21 00:18:03 +0100 (CET)
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem

View full thread Coderef auf unbekannt