In preparation of trying to suggest a replacement for your switch use i would like to start with this comment

$t[++$#t]=threads->new(\&adminpass); seems to be a real verbose way of saying push @t,threads->new(\&adminpass);

It looks like your use of switch is to process a comma separated list of commands. a simple replacement for

switch($action) { case /adminpass(,|$)/ { print "Do adminpass ($hostname)\n" if($verbose || $debug); $t[++$#t]=threads->new(\&adminpass); next; } # end case /adminpass/ case /backup(,|$)/ { print "Do backup ($hostname)\n" if($verbose || $debug); $t[++$#t]=threads->new(\&backup); next; } # end case /backup/ case /buildhosts(,|$)/ { print "Do buildhosts ($hostname)\n" if($verbose || $debug); $t[++$#t]=threads->new(\&buildhosts); next; } # end case /buildhosts/ case /buildhostsdell(,|$)/ { print "Do buildhostsdell ($hostname)\n" if($verbose || $debug +); $t[++$#t]=threads->new(\&buildhostsdell); next; } # end case /buildhostsdell/ ... }
might be
if ($action=~/adminpass(,|$)/) { print "Do adminpass ($hostname)\n" if($verbose || $debug); push @t,threads->new(\&adminpass); } # end case /adminpass/ if ($action=~/backup(,|$)/) { print "Do backup ($hostname)\n" if($verbose || $debug); push @t,threads->new(\&backup); } # end case /backup/ if ($action=~/buildhosts(,|$)/) { print "Do buildhosts ($hostname)\n" if($verbose || $debug); push @t,threads->new(\&buildhosts); } # end case /buildhosts/ if ($action=~/buildhostsdell(,|$)/) { print "Do buildhostsdell ($hostname)\n" if($verbose || $debug +); push @t,threads->new(\&buildhostsdell); } # end case /buildhostsdell/ ...
but a more efficient and direct solution may be as follows
# create a list of the command names and the subroutines they call my %cmds=(adminpass =>\&adminpass, backup =>\&backup, buildhosts =>\&buildhosts, buildhostsdell =>\&buildhostsdell ); # break list of comma sep commands into words # and if we have a subroutine for that word start a thread with it for my $cmd (split(',',$action)) { if (exists $cmds{$cmd}) { print "Do $cmd ($hostname)\n" if($verbose || $debug); push @t,threads->new($cmds{$cmd}); } else { print "Command $cmd unknown\n"; } }


In reply to Re: defunct process are WAY beyond my experienc by huck
in thread defunct process are WAY beyond my experienc by cristj1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.