my $cmd = "cd /cat/bat"; system($cmd); if ($? == -1) { print "Command failed"; }