Debian Codegraph @

Ref_Data/reply.cdump_ref

raw
1
2 $Heading='Menu 1';
3
4 # Code generated by Shell::POSIX::Select v0.09, by tim(AT)TeachMePerl.com
5 # NOTA BENE: Line 1 of this segment must start with {, so user can LABEL it
6 { # **** NEW WRAPPER SCOPE FOR SELECTLOOP #1 ****
7 $Shell::POSIX::Select::DEBUG > 1 and 1 == 1 and
8 warn "LINE NUMBER FOR START OF USER CODE_BLOCK IS: ", __LINE__, "\n";
9 _SEL_LOOP1: { # **** NEW SCOPE FOR SELECTLOOP #1 ****
10
11 # critical for values's contents to be resolved in user's scope
12 local @Shell::POSIX::Select::looplist=(1,2);
13 local $Shell::POSIX::Select::num_values=@Shell::POSIX::Select::looplist;
14
15 $Shell::POSIX::Select::DEBUG > 4 and do {
16 warn "ARRAY VALUES ARE: @Shell::POSIX::Select::looplist\n";
17 warn "NUM VALUES is $Shell::POSIX::Select::num_values\n";
18 warn "user-program debug level is $Shell::POSIX::Select::U_WARN\n";
19 };
20 my $var; # LOOP-VAR DECLARATION REQUESTED (perhaps by default) # loop-var declaration appears here
21
22 ;
23 local (
24 $Shell::POSIX::Select::Prompt[1],
25 $Shell::POSIX::Select::menu
26 ) =
27 Shell::POSIX::Select::make_menu(
28 $Shell::POSIX::Select::Heading || "",
29 $Shell::POSIX::Select::Prompt || "" , # Might be overridden in make_menu
30 @Shell::POSIX::Select::looplist
31 );
32
33 # no point in prompting a pipe!
34 local $Shell::POSIX::Select::do_prompt[1] = (-t) ? 1 : 0 ;
35 0 > 2 and warn "do_prompt is $Shell::POSIX::Select::do_prompt[1]\n";
36 if ( defined $Shell::POSIX::Select::menu ) { # No list, no iterations!
37 while (1) { # for repeating prompt for selections
38 # localize, so I don't have to reset for
39 # outer loop on exit from inner
40 local ($Reply);
41 while (1) { # for validating user's input
42 local $Shell::POSIX::Select::bad = 0;
43
44 # local decl suppresses newline on prompt when -l switch turned on
45 {
46 local $\;
47 if ($Shell::POSIX::Select::do_prompt[1]) {
48
49 # When transferring from INNER to OUTER loop,
50 # extra NL before prompt is visually desirable
51
52 if ( $Shell::POSIX::Select::_extra_nl) {
53 print STDERR "\n\n";
54 $Shell::POSIX::Select::_extra_nl=0;
55 }
56 print STDERR
57 "$Shell::POSIX::Select::menu\n$Shell::POSIX::Select::Prompt[1] ";
58 }
59 }
60
61 # $Shell::POSIX::Select::do_prompt=0;
62 # constant prompting depends on style
63 $Shell::POSIX::Select::do_prompt[1]= 0;
64
65 if ( $Shell::POSIX::Select::dump_data ) {
66 $Reply = undef;
67 # dump filtered source for comparison against expected
68 print STDERR "copacetic
69 "; # ensure some output, and flush pending
70 exit 222; # code for graceful, expected, early exit
71 }
72 else {
73 # $^W=0;
74 # warn "Waiting for input";
75 $Eof=0;
76 $Reply = <STDIN>;
77 # warn "Got input";
78 # $^W=1;
79
80 if ( !defined( $Reply ) ) {
81 defined "" and "" ne "" and print STDERR "";
82
83 # need to undef loop var; user may check it!
84 undef $var;
85
86 # last Shell::POSIX::Select::_SEL_LOOP1; # Syntax error!
87 # If returning to outer loop, show the prompt for it
88 # warn "User hit ^D";
89 if ( 1 > 1 and -t ) { # reset prompting for outer loop
90 $Shell::POSIX::Select::do_prompt[1-1] = 1; $Shell::POSIX::Select::_extra_nl=1;
91 }
92 0 > 2 and warn "Lasting out of _SEL_LOOP1\n";
93 $Eof=1;
94 last _SEL_LOOP1;
95 }
96 !defined $Reply and die "REPLY accessed, while undefined";
97 chomp $Reply;
98
99 # undo emboldening of user input
100 defined "" and "" ne "" and print STDERR "";
101
102 #print STDERR "$Shell::POSIX::Select::menu\n$Shell::POSIX::Select::Prompt ";
103 if ( $Reply eq "" ) { # interpreted as re-print menu request
104 # Empty input is legit, means redisplay menu
105 $Shell::POSIX::Select::U_WARN > 1 and warn "\tINPUT IS: empty\n";
106 $Shell::POSIX::Select::bad = $Shell::POSIX::Select::do_prompt[1] = 1;
107 }
108 elsif ( $Reply =~ /\D/ ) { # shouldn't be any non-digit!
109 $Shell::POSIX::Select::U_WARN > 0
110 and warn "\tINPUT CONTAINS NON-DIGIT: '$Reply'\n";
111 $Shell::POSIX::Select::bad = 1; # Korn and Bash shell just ignore this case
112 }
113 elsif ( $Reply < 1 or $Reply > $Shell::POSIX::Select::num_values ) {
114 $Shell::POSIX::Select::U_WARN > 0
115 and warn
116 "\t'$Reply' IS NOT IN RANGE: 1 - $Shell::POSIX::Select::num_values\n";
117 $Shell::POSIX::Select::bad = 1; # Korn and Bash shell just ignore this case
118 }
119
120 # warn "BAD is now: $Shell::POSIX::Select::bad";
121 $Shell::POSIX::Select::bad or
122 0 > 2 and warn "About to last out of Reply Validator Loop
123 ";
124 $Shell::POSIX::Select::bad or last; # REPLY VALIDATOR EXITED HERE
125 } # if for validating user input
126 } # infinite while for validating user input
127
128 $var = $Shell::POSIX::Select::looplist[$Reply - 1]; # set users' variable
129
130 # USER'S LOOP-BLOCK BELOW
131 warn "inside Outer loop\n";
132 warn "Reply is $Reply\n";
133
134 $Heading='Menu 2';
135
136 # Code generated by Shell::POSIX::Select v0.09, by tim(AT)TeachMePerl.com
137 # NOTA BENE: Line 1 of this segment must start with {, so user can LABEL it
138 { # **** NEW WRAPPER SCOPE FOR SELECTLOOP #2 ****
139 $Shell::POSIX::Select::DEBUG > 1 and 2 == 1 and
140 warn "LINE NUMBER FOR START OF USER CODE_BLOCK IS: ", __LINE__, "\n";
141 _SEL_LOOP2: { # **** NEW SCOPE FOR SELECTLOOP #2 ****
142
143 # critical for values's contents to be resolved in user's scope
144 local @Shell::POSIX::Select::looplist=(qw (a b) );
145 local $Shell::POSIX::Select::num_values=@Shell::POSIX::Select::looplist;
146
147 $Shell::POSIX::Select::DEBUG > 4 and do {
148 warn "ARRAY VALUES ARE: @Shell::POSIX::Select::looplist\n";
149 warn "NUM VALUES is $Shell::POSIX::Select::num_values\n";
150 warn "user-program debug level is $Shell::POSIX::Select::U_WARN\n";
151 };
152 my $var2; # LOOP-VAR DECLARATION REQUESTED (perhaps by default) # loop-var declaration appears here
153
154 ;
155 local (
156 $Shell::POSIX::Select::Prompt[2],
157 $Shell::POSIX::Select::menu
158 ) =
159 Shell::POSIX::Select::make_menu(
160 $Shell::POSIX::Select::Heading || "",
161 $Shell::POSIX::Select::Prompt || "" , # Might be overridden in make_menu
162 @Shell::POSIX::Select::looplist
163 );
164
165 # no point in prompting a pipe!
166 local $Shell::POSIX::Select::do_prompt[2] = (-t) ? 1 : 0 ;
167 0 > 2 and warn "do_prompt is $Shell::POSIX::Select::do_prompt[2]\n";
168 if ( defined $Shell::POSIX::Select::menu ) { # No list, no iterations!
169 while (1) { # for repeating prompt for selections
170 # localize, so I don't have to reset for
171 # outer loop on exit from inner
172 local ($Reply);
173 while (1) { # for validating user's input
174 local $Shell::POSIX::Select::bad = 0;
175
176 # local decl suppresses newline on prompt when -l switch turned on
177 {
178 local $\;
179 if ($Shell::POSIX::Select::do_prompt[2]) {
180
181 # When transferring from INNER to OUTER loop,
182 # extra NL before prompt is visually desirable
183
184 if ( $Shell::POSIX::Select::_extra_nl) {
185 print STDERR "\n\n";
186 $Shell::POSIX::Select::_extra_nl=0;
187 }
188 print STDERR
189 "$Shell::POSIX::Select::menu\n$Shell::POSIX::Select::Prompt[2] ";
190 }
191 }
192
193 # $Shell::POSIX::Select::do_prompt=0;
194 # constant prompting depends on style
195 $Shell::POSIX::Select::do_prompt[2]= 0;
196
197 if ( $Shell::POSIX::Select::dump_data ) {
198 $Reply = undef;
199 # dump filtered source for comparison against expected
200 print STDERR "copacetic
201 "; # ensure some output, and flush pending
202 exit 222; # code for graceful, expected, early exit
203 }
204 else {
205 # $^W=0;
206 # warn "Waiting for input";
207 $Eof=0;
208 $Reply = <STDIN>;
209 # warn "Got input";
210 # $^W=1;
211
212 if ( !defined( $Reply ) ) {
213 defined "" and "" ne "" and print STDERR "";
214
215 # need to undef loop var; user may check it!
216 undef $var2;
217
218 # last Shell::POSIX::Select::_SEL_LOOP2; # Syntax error!
219 # If returning to outer loop, show the prompt for it
220 # warn "User hit ^D";
221 if ( 2 > 1 and -t ) { # reset prompting for outer loop
222 $Shell::POSIX::Select::do_prompt[2-1] = 1; $Shell::POSIX::Select::_extra_nl=1;
223 }
224 0 > 2 and warn "Lasting out of _SEL_LOOP2\n";
225 $Eof=1;
226 last _SEL_LOOP2;
227 }
228 !defined $Reply and die "REPLY accessed, while undefined";
229 chomp $Reply;
230
231 # undo emboldening of user input
232 defined "" and "" ne "" and print STDERR "";
233
234 #print STDERR "$Shell::POSIX::Select::menu\n$Shell::POSIX::Select::Prompt ";
235 if ( $Reply eq "" ) { # interpreted as re-print menu request
236 # Empty input is legit, means redisplay menu
237 $Shell::POSIX::Select::U_WARN > 1 and warn "\tINPUT IS: empty\n";
238 $Shell::POSIX::Select::bad = $Shell::POSIX::Select::do_prompt[2] = 1;
239 }
240 elsif ( $Reply =~ /\D/ ) { # shouldn't be any non-digit!
241 $Shell::POSIX::Select::U_WARN > 0
242 and warn "\tINPUT CONTAINS NON-DIGIT: '$Reply'\n";
243 $Shell::POSIX::Select::bad = 1; # Korn and Bash shell just ignore this case
244 }
245 elsif ( $Reply < 1 or $Reply > $Shell::POSIX::Select::num_values ) {
246 $Shell::POSIX::Select::U_WARN > 0
247 and warn
248 "\t'$Reply' IS NOT IN RANGE: 1 - $Shell::POSIX::Select::num_values\n";
249 $Shell::POSIX::Select::bad = 1; # Korn and Bash shell just ignore this case
250 }
251
252 # warn "BAD is now: $Shell::POSIX::Select::bad";
253 $Shell::POSIX::Select::bad or
254 0 > 2 and warn "About to last out of Reply Validator Loop
255 ";
256 $Shell::POSIX::Select::bad or last; # REPLY VALIDATOR EXITED HERE
257 } # if for validating user input
258 } # infinite while for validating user input
259
260 $var2 = $Shell::POSIX::Select::looplist[$Reply - 1]; # set users' variable
261
262 # USER'S LOOP-BLOCK BELOW
263 warn "inside Inner loop\n";
264 warn "Reply is $Reply\n";
265 print "$var$var2\n";
266 last;;
267
268 # USER'S LOOP-BLOCK ABOVE
269 # Making sure there's colon (maybe
270 # even two) after codestring above,
271 # in case user omitted after last
272 # statement in block. I might add
273 # another statement below it someday!
274 0 > 2 and warn "At end of prompt-repeating loop
275 ";
276 } # infinite while for repeating collection of selections
277 0 and warn "BEYOND end of prompt-repeating loop
278 ";
279 } # endif (defined $Shell::POSIX::Select::menu)
280 else {
281 $Shell::POSIX::Select::DEBUG > 0 and warn "Shell::POSIX::Select: Select Loop #2 has no list, so no iterations\n";
282
283 if ( $Shell::POSIX::Select::dump_data ) {
284 $Reply = undef;
285 # dump filtered source for comparison against expected
286 print STDERR "copacetic
287 "; # ensure some output, and flush pending
288 exit 222; # code for graceful, expected, early exit
289 }
290 }
291 # return omitted above, to get last expression's value
292 # returned automatically, just like shell's version
293
294
295 } # **** END NEW SCOPE FOR SELECTLOOP #2 ****
296 } # **** END WRAPPER SCOPE FOR SELECTLOOP #2 ****
297 # vi:ts=2 sw=2:
298
299 warn "outside Inner loop\n";
300 warn "Reply is $Reply\n";;
301
302 # USER'S LOOP-BLOCK ABOVE
303 # Making sure there's colon (maybe
304 # even two) after codestring above,
305 # in case user omitted after last
306 # statement in block. I might add
307 # another statement below it someday!
308 0 > 2 and warn "At end of prompt-repeating loop
309 ";
310 } # infinite while for repeating collection of selections
311 0 and warn "BEYOND end of prompt-repeating loop
312 ";
313 } # endif (defined $Shell::POSIX::Select::menu)
314 else {
315 $Shell::POSIX::Select::DEBUG > 0 and warn "Shell::POSIX::Select: Select Loop #1 has no list, so no iterations\n";
316
317 if ( $Shell::POSIX::Select::dump_data ) {
318 $Reply = undef;
319 # dump filtered source for comparison against expected
320 print STDERR "copacetic
321 "; # ensure some output, and flush pending
322 exit 222; # code for graceful, expected, early exit
323 }
324 }
325 # return omitted above, to get last expression's value
326 # returned automatically, just like shell's version
327
328
329 } # **** END NEW SCOPE FOR SELECTLOOP #1 ****
330 } # **** END WRAPPER SCOPE FOR SELECTLOOP #1 ****
331 # vi:ts=2 sw=2:
332
333 warn "outside all loops\n";