sub kill_process { print "Kill processes for the user? (y or n)?\n"; my $ans = <>; while ($ans =~ /^Y/i) { print "Enter pid to kill:\n"; my $pid = <>; chomp $pid; if (is_valid($pid)) { `kill $pid`; print "Process $pid killed\n"; } else { print "Process $pid is invalid\n"; } print "Kill more processes for the user? (y or n)?\n"; my $ans = <>; } }