On line 170 :
] elsif ($! != &ENOENT){
should be
] elsif ($| != &ENOENT){
note the pipe instead of the exclamation mark.
Right now it compares the error string "no such files ... "against
ENOENT which is 2.
$| is the way to retrieve the error value.
This way the error "failed to open ..." is shown when using :
update-alternatives --list foobar
Cheers
Alban