use strict; use warnings; use threads; my ($thr, @threads); INPUT: print "What do you want me to do?\n"; my $work = ; chomp $work; if ($work eq "permissions") { $thr = threads->create(sub { print `sh /root/scripts/security.sh` }); push(@threads, $thr); #keep track of the thread print "security.sh sent into background\n"; goto INPUT; } elsif ($work eq "apachelog") { $thr = threads->create(sub { print `perl /root/scripts/apachelog.pl` }); push(@threads, $thr); #keep track of the thread print "apachelog.pl sent into background.\n"; goto INPUT; } elsif ($work eq "exit") { $_->join() for @threads; # cause threads to return home after finishing. exit 0; }