>From Tollef Fog Heen comments on my patch in #246906 (that $| has nothing to do with error values but flush), i began to doubt about those patch. With them applied everything work as it should , proper errors strings are showned, etc ... It may be just by luck , please consider asking to a formal perl coder.
I checked the other perl script in dpkg and only dpkg-divert had simialr problems (not erroring after opening, linking ... a non existant file or such). Patch attached Alban
--- dpkg-divert.orig 2005-01-20 22:56:10.260732712 +0100 +++ dpkg-divert 2005-01-20 22:57:45.775212304 +0100 @@ -208,9 +208,9 @@ sub checkrename { return unless $dorename; ($rsrc,$rdest) = @_; - (@ssrc= lstat($rsrc)) || $! == &ENOENT || + (@ssrc= lstat($rsrc)) || $| == &ENOENT || &quit("cannot stat old name \`$rsrc': $!"); - (@sdest= lstat($rdest)) || $! == &ENOENT || + (@sdest= lstat($rdest)) || $| == &ENOENT || &quit("cannot stat new name \`$rdest': $!"); # Unfortunately we have to check for write access in both # places, just having +w is not enough, since people do @@ -223,7 +223,7 @@ if (open (TMP, ">> ${file}.dpkg-devert.tmp")) { close TMP; unlink ("${file}.dpkg-devert.tmp"); - } elsif ($! == ENOENT) { + } elsif ($| == &ENOENT) { $dorename = !$dorename; } else { &quit("error checking \`$file': $!"); @@ -258,9 +258,9 @@ } close(N) || &quit("close diversions-new: $!"); unlink("$admindir/diversions-old") || - $! == &ENOENT || &quit("remove old diversions-old: $!"); + $| == &ENOENT || &quit("remove old diversions-old: $!"); link("$admindir/diversions","$admindir/diversions-old") || - $! == &ENOENT || &quit("create new diversions-old: $!"); + $| == &ENOENT || &quit("create new diversions-old: $!"); rename("$admindir/diversions-new","$admindir/diversions") || &quit("install new diversions: $!"); }