Thread "or die $!" bei Funktionsaufruf (16 answers)
Opened by bloonix at 2006-05-18 16:42

pq
 2006-05-18 16:53
#66274 #66274
User since
2003-08-04
12208 Artikel
Admin1
[Homepage]
user image
auszug aus der doku:
Code: (dl )
1
2
3
4
       $!      If used numerically, yields the current value of the C "errno"
              variable, or in other words, if a system or library call fails,
              it sets this variable.  This means that the value of $! is
              meaningful only immediately after a failure:


was du willst, ist:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
sub do_open {
 # ./datei gibt es nicht
 open my $FH,'<','./datei' or die $!;
}

.....

eval {
 do_open()
} or die "Fehler: $@";
\n\n

<!--EDIT|pq|1147956821-->
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 "or die $!" bei Funktionsaufruf