You are setting $exit to be the opposite of what 'run' returns. You want
in reply to Return Values from IPC::Run
just like you should write
run ... and $exit = 1;
these being a couple of the rare Perl functions that return 0, a false value, to indicate "no failure" instead of the much more usual "true means success" scheme.
system( ... ) and die ...
Update: Checking the documentation, I couldn't find any direct mention of what run() returns but it was certainly used as if "true means success" and looking at the source, it appears to return the equivalent of ! $?. So my instinct and advice was wrong. Sorry. It just fit the problem statement so well. Drat. But your claim of what $? returned contradicts this so maybe you've got some version that I'd have to dig out of backpan and I'm actually right after all. ;->