Debian Codegraph @

Ref_Data/argv_heading.cdump_ref

raw
1
2 BEGIN { @ARGV or @ARGV=qw(A B C) }
3
4 $Heading='MENU CITY';
5
6 # Code generated by Shell::POSIX::Select v0.09, by tim(AT)TeachMePerl.com
7 # NOTA BENE: Line 1 of this segment must start with {, so user can LABEL it
8 { # **** NEW WRAPPER SCOPE FOR SELECTLOOP #1 ****
9 $Shell::POSIX::Select::DEBUG > 1 and 1 == 1 and
10 warn "LINE NUMBER FOR START OF USER CODE_BLOCK IS: ", __LINE__, "\n";
11 _SEL_LOOP1: { # **** NEW SCOPE FOR SELECTLOOP #1 ****
12
13 # critical for values's contents to be resolved in user's scope
14 local @Shell::POSIX::Select::looplist=(@ARGV);
15 local $Shell::POSIX::Select::num_values=@Shell::POSIX::Select::looplist;
16
17 $Shell::POSIX::Select::DEBUG > 4 and do {
18 warn "ARRAY VALUES ARE: @Shell::POSIX::Select::looplist\n";
19 warn "NUM VALUES is $Shell::POSIX::Select::num_values\n";
20 warn "user-program debug level is $Shell::POSIX::Select::U_WARN\n";
21 };
22 ; # NO DECLARATION OF LOOP-VAR REQUESTED # loop-var declaration appears here
23
24 ;
25 local (
26 $Shell::POSIX::Select::Prompt[1],
27 $Shell::POSIX::Select::menu
28 ) =
29 Shell::POSIX::Select::make_menu(
30 $Shell::POSIX::Select::Heading || "",
31 $Shell::POSIX::Select::Prompt || "" , # Might be overridden in make_menu
32 @Shell::POSIX::Select::looplist
33 );
34
35 # no point in prompting a pipe!
36 local $Shell::POSIX::Select::do_prompt[1] = (-t) ? 1 : 0 ;
37 0 > 2 and warn "do_prompt is $Shell::POSIX::Select::do_prompt[1]\n";
38 if ( defined $Shell::POSIX::Select::menu ) { # No list, no iterations!
39 while (1) { # for repeating prompt for selections
40 # localize, so I don't have to reset for
41 # outer loop on exit from inner
42 local ($Reply);
43 while (1) { # for validating user's input
44 local $Shell::POSIX::Select::bad = 0;
45
46 # local decl suppresses newline on prompt when -l switch turned on
47 {
48 local $\;
49 if ($Shell::POSIX::Select::do_prompt[1]) {
50
51 # When transferring from INNER to OUTER loop,
52 # extra NL before prompt is visually desirable
53
54 if ( $Shell::POSIX::Select::_extra_nl) {
55 print STDERR "\n\n";
56 $Shell::POSIX::Select::_extra_nl=0;
57 }
58 print STDERR
59 "$Shell::POSIX::Select::menu\n$Shell::POSIX::Select::Prompt[1] ";
60 }
61 }
62
63 # $Shell::POSIX::Select::do_prompt=0;
64 # constant prompting depends on style
65 $Shell::POSIX::Select::do_prompt[1]= 0;
66
67 if ( $Shell::POSIX::Select::dump_data ) {
68 $Reply = undef;
69 # dump filtered source for comparison against expected
70 print STDERR "copacetic
71 "; # ensure some output, and flush pending
72 exit 222; # code for graceful, expected, early exit
73 }
74 else {
75 # $^W=0;
76 # warn "Waiting for input";
77 $Eof=0;
78 $Reply = <STDIN>;
79 # warn "Got input";
80 # $^W=1;
81
82 if ( !defined( $Reply ) ) {
83 defined "" and "" ne "" and print STDERR "";
84
85 # need to undef loop var; user may check it!
86 undef $var;
87
88 # last Shell::POSIX::Select::_SEL_LOOP1; # Syntax error!
89 # If returning to outer loop, show the prompt for it
90 # warn "User hit ^D";
91 if ( 1 > 1 and -t ) { # reset prompting for outer loop
92 $Shell::POSIX::Select::do_prompt[1-1] = 1; $Shell::POSIX::Select::_extra_nl=1;
93 }
94 0 > 2 and warn "Lasting out of _SEL_LOOP1\n";
95 $Eof=1;
96 last _SEL_LOOP1;
97 }
98 !defined $Reply and die "REPLY accessed, while undefined";
99 chomp $Reply;
100
101 # undo emboldening of user input
102 defined "" and "" ne "" and print STDERR "";
103
104 #print STDERR "$Shell::POSIX::Select::menu\n$Shell::POSIX::Select::Prompt ";
105 if ( $Reply eq "" ) { # interpreted as re-print menu request
106 # Empty input is legit, means redisplay menu
107 $Shell::POSIX::Select::U_WARN > 1 and warn "\tINPUT IS: empty\n";
108 $Shell::POSIX::Select::bad = $Shell::POSIX::Select::do_prompt[1] = 1;
109 }
110 elsif ( $Reply =~ /\D/ ) { # shouldn't be any non-digit!
111 $Shell::POSIX::Select::U_WARN > 0
112 and warn "\tINPUT CONTAINS NON-DIGIT: '$Reply'\n";
113 $Shell::POSIX::Select::bad = 1; # Korn and Bash shell just ignore this case
114 }
115 elsif ( $Reply < 1 or $Reply > $Shell::POSIX::Select::num_values ) {
116 $Shell::POSIX::Select::U_WARN > 0
117 and warn
118 "\t'$Reply' IS NOT IN RANGE: 1 - $Shell::POSIX::Select::num_values\n";
119 $Shell::POSIX::Select::bad = 1; # Korn and Bash shell just ignore this case
120 }
121
122 # warn "BAD is now: $Shell::POSIX::Select::bad";
123 $Shell::POSIX::Select::bad or
124 0 > 2 and warn "About to last out of Reply Validator Loop
125 ";
126 $Shell::POSIX::Select::bad or last; # REPLY VALIDATOR EXITED HERE
127 } # if for validating user input
128 } # infinite while for validating user input
129
130 $var = $Shell::POSIX::Select::looplist[$Reply - 1]; # set users' variable
131
132 # USER'S LOOP-BLOCK BELOW
133 print "$var\n";;
134
135 # USER'S LOOP-BLOCK ABOVE
136 # Making sure there's colon (maybe
137 # even two) after codestring above,
138 # in case user omitted after last
139 # statement in block. I might add
140 # another statement below it someday!
141 0 > 2 and warn "At end of prompt-repeating loop
142 ";
143 } # infinite while for repeating collection of selections
144 0 and warn "BEYOND end of prompt-repeating loop
145 ";
146 } # endif (defined $Shell::POSIX::Select::menu)
147 else {
148 $Shell::POSIX::Select::DEBUG > 0 and warn "Shell::POSIX::Select: Select Loop #1 has no list, so no iterations\n";
149
150 if ( $Shell::POSIX::Select::dump_data ) {
151 $Reply = undef;
152 # dump filtered source for comparison against expected
153 print STDERR "copacetic
154 "; # ensure some output, and flush pending
155 exit 222; # code for graceful, expected, early exit
156 }
157 }
158 # return omitted above, to get last expression's value
159 # returned automatically, just like shell's version
160
161
162 } # **** END NEW SCOPE FOR SELECTLOOP #1 ****
163 } # **** END WRAPPER SCOPE FOR SELECTLOOP #1 ****
164 # vi:ts=2 sw=2:
165