perl -e 'open(C,"ls foo.bar 2>&1 |") or die $!; while(){ print "I got the error\n" if (/No such/) }'