my $result=`sudo /bin/mount /dev/fd0 /mnt/floppy`; if ($?) { # there was an non zero return code print "There was an error: $?\n"; print $result } else { # looks like it worked }