As another poster mentioned, you're not quite fetching the error status correctly. As it is now, if
$result is non-zero, it's indicating a failure (counter to the usual behavior). In addition, your server's error logs should contain a textual description of
why the 'rm' command failed (as it would have printed its message to STDERR, which would have gone to the server's error logs). While you're debugging, you may want to make use of
CGI::Carp to send your errors straight to the browser:
use CGI::Carp 'fatalsToBrowser';