#!perl use strict; use warnings; exec 'ssh', join '@', 'brannont', menu( [qw( secdevfdsapp01 dopey bonnie )], "\n\nssh hosts\n---------\n", "\n\nssh to: " ); # returns one of the items in the array passed as the first arg sub menu { my( $ar, $hdr, $prompt ) = @_; local @ARGV; { print $hdr if defined $hdr; print "[$_] $ar->[$_]\n" for 0 .. $#{$ar}; print $prompt if defined $prompt; my $c = <>; chomp $c; return $ar->[$c] if $c =~ /^\d+$/ && $c >= 0 && $c <= $#{$ar}; print "invalid choice\n"; redo; } }