Skip to content

Instantly share code, notes, and snippets.

@earnhardt3rd
Created June 19, 2023 13:56
Show Gist options
  • Select an option

  • Save earnhardt3rd/c6214466f3f30e0895f2f3f355cf567c to your computer and use it in GitHub Desktop.

Select an option

Save earnhardt3rd/c6214466f3f30e0895f2f3f355cf567c to your computer and use it in GitHub Desktop.
require 'getopts.pl';
Getopts('m:d:t');
my $MODE = uc($opt_m) || "";
my $DEBUG = $opt_d || 0;
if (defined $opt_t) { my %TEST = &fromARRAY_NOEXIT();}
1;
sub fromARRAY_NOEXIT {
print " =============== FROM ARRAY ===============\n" if $DEBUG > 0;
my @ARRAY = @_;
my @RETURN;
my $ans="";
if (uc($MODE) ne "NO-PROMPT") {
for (my $i=0;$i<=scalar(@ARRAY)-1 ;$i++) {
my $c = $i+1;
print "\t$c $ARRAY[$i]\n";
}
print "\n\tEnter Choice (x~exit| s~skip) 1,2,ect | 1-5,8-19 | a for all] [a]:";
$ans = <STDIN>;
chomp($ans);
print "\n";
if (lc($ans) eq "x") {
return;
}
if (lc($ans) eq "s") {return;}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment