Thread filehandleproblem (13 answers)
Opened by Noisebreath at 2006-09-20 15:36

pq
 2006-09-21 09:35
#70121 #70121
User since
2003-08-04
12209 Artikel
Admin1
[Homepage]
user image
[quote=Noisebreath,20.09.2006, 14:27]doch ich benutze strict[/quote]
wenn du strict benutzen würdest, hättest du eine andere fehlermeldung
bekommen, $fh wäre nämlich an der stelle gar nicht deklariert gewesen.
es hilft nicht, einfach zu sagen, dass man strict benutzt, wenn man es nicht tut.
hier ein beispiel:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
$ perl -wle'
if (1) {
 my $fh = "foo";
}
else {
 my $fh = "bar";
}
print $fh'
Name "main::fh" used only once: possible typo at -e line 8.
Use of uninitialized value in print at -e line 8.

mit strict:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
$ perl -Mstrict -wle'
if (1) {
 my $fh = "foo";
}
else {
 my $fh = "bar";
}
print $fh'
Global symbol "$fh" requires explicit package name at -e line 8.
Execution of -e aborted due to compilation errors.
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 filehandleproblem