Thread Ungewöhnliches Benchmarkergebnis (21 answers)
Opened by ppm1 at 2004-05-27 00:23

sri
 2004-05-30 04:20
#82795 #82795
User since
2004-01-29
828 Artikel
BenutzerIn
[Homepage] [default_avatar]
[quote=Strat,30.05.2004, 00:03]Das einzige, was our gegenueber use vars mehr hat ist, dass man es ueber packagegrenzen hinweg verwenden kann, weil da intern automatisch das package vorangesetzt wird, wobei es aber trotzdem eine package-Variable ist, wie die obigen codebeispiele gut zeigen.[/quote]
Sobald use strict vars verwendet wird (wer tut das nicht?:-) ist dem nicht mehr so.

Dann kann $var nämlich nur innerhalb ihres lexical scope ohne vorangestelltes package verwendet werden.

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
sri@odyssey:~$ cat test.pl
use strict;
use vars '$rav';
$rav = 10;
Test: {
our $var = 20;
print "var: $var\n";
}
print "rav: $rav, var: $var\n";
sri@odyssey:~$ perl test.pl
Variable "$var" is not imported at test.pl line 8.
Global symbol "$var" requires explicit package name at test.pl line 8.
Execution of test.pl aborted due to compilation errors.

View full thread Ungewöhnliches Benchmarkergebnis