Debian Codegraph @

Ref_Data/prompt.nested.cdump_ref

raw
1
2 $Prompt='Custom Prompt for loop 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 );
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 local $_; # 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 $_;
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 $_ = $Shell::POSIX::Select::looplist[$Reply - 1]; # set users' variable
129
130 # USER'S LOOP-BLOCK BELOW
131 $Prompt='Custom Prompt for loop 2';
132 LOOP2:
133
134 # Code generated by Shell::POSIX::Select v0.09, by tim(AT)TeachMePerl.com
135 # NOTA BENE: Line 1 of this segment must start with {, so user can LABEL it
136 { # **** NEW WRAPPER SCOPE FOR SELECTLOOP #2 ****
137 $Shell::POSIX::Select::DEBUG > 1 and 2 == 1 and
138 warn "LINE NUMBER FOR START OF USER CODE_BLOCK IS: ", __LINE__, "\n";
139 _SEL_LOOP2: { # **** NEW SCOPE FOR SELECTLOOP #2 ****
140
141 # critical for values's contents to be resolved in user's scope
142 local @Shell::POSIX::Select::looplist=( 2 );
143 local $Shell::POSIX::Select::num_values=@Shell::POSIX::Select::looplist;
144
145 $Shell::POSIX::Select::DEBUG > 4 and do {
146 warn "ARRAY VALUES ARE: @Shell::POSIX::Select::looplist\n";
147 warn "NUM VALUES is $Shell::POSIX::Select::num_values\n";
148 warn "user-program debug level is $Shell::POSIX::Select::U_WARN\n";
149 };
150 local $_; # LOOP-VAR DECLARATION REQUESTED (perhaps by default) # loop-var declaration appears here
151
152 ;
153 local (
154 $Shell::POSIX::Select::Prompt[2],
155 $Shell::POSIX::Select::menu
156 ) =
157 Shell::POSIX::Select::make_menu(
158 $Shell::POSIX::Select::Heading || "",
159 $Shell::POSIX::Select::Prompt || "" , # Might be overridden in make_menu
160 @Shell::POSIX::Select::looplist
161 );
162
163 # no point in prompting a pipe!
164 local $Shell::POSIX::Select::do_prompt[2] = (-t) ? 1 : 0 ;
165 0 > 2 and warn "do_prompt is $Shell::POSIX::Select::do_prompt[2]\n";
166 if ( defined $Shell::POSIX::Select::menu ) { # No list, no iterations!
167 while (1) { # for repeating prompt for selections
168 # localize, so I don't have to reset for
169 # outer loop on exit from inner
170 local ($Reply);
171 while (1) { # for validating user's input
172 local $Shell::POSIX::Select::bad = 0;
173
174 # local decl suppresses newline on prompt when -l switch turned on
175 {
176 local $\;
177 if ($Shell::POSIX::Select::do_prompt[2]) {
178
179 # When transferring from INNER to OUTER loop,
180 # extra NL before prompt is visually desirable
181
182 if ( $Shell::POSIX::Select::_extra_nl) {
183 print STDERR "\n\n";
184 $Shell::POSIX::Select::_extra_nl=0;
185 }
186 print STDERR
187 "$Shell::POSIX::Select::menu\n$Shell::POSIX::Select::Prompt[2] ";
188 }
189 }
190
191 # $Shell::POSIX::Select::do_prompt=0;
192 # constant prompting depends on style
193 $Shell::POSIX::Select::do_prompt[2]= 0;
194
195 if ( $Shell::POSIX::Select::dump_data ) {
196 $Reply = undef;
197 # dump filtered source for comparison against expected
198 print STDERR "copacetic
199 "; # ensure some output, and flush pending
200 exit 222; # code for graceful, expected, early exit
201 }
202 else {
203 # $^W=0;
204 # warn "Waiting for input";
205 $Eof=0;
206 $Reply = <STDIN>;
207 # warn "Got input";
208 # $^W=1;
209
210 if ( !defined( $Reply ) ) {
211 defined "" and "" ne "" and print STDERR "";
212
213 # need to undef loop var; user may check it!
214 undef $_;
215
216 # last Shell::POSIX::Select::_SEL_LOOP2; # Syntax error!
217 # If returning to outer loop, show the prompt for it
218 # warn "User hit ^D";
219 if ( 2 > 1 and -t ) { # reset prompting for outer loop
220 $Shell::POSIX::Select::do_prompt[2-1] = 1; $Shell::POSIX::Select::_extra_nl=1;
221 }
222 0 > 2 and warn "Lasting out of _SEL_LOOP2\n";
223 $Eof=1;
224 last _SEL_LOOP2;
225 }
226 !defined $Reply and die "REPLY accessed, while undefined";
227 chomp $Reply;
228
229 # undo emboldening of user input
230 defined "" and "" ne "" and print STDERR "";
231
232 #print STDERR "$Shell::POSIX::Select::menu\n$Shell::POSIX::Select::Prompt ";
233 if ( $Reply eq "" ) { # interpreted as re-print menu request
234 # Empty input is legit, means redisplay menu
235 $Shell::POSIX::Select::U_WARN > 1 and warn "\tINPUT IS: empty\n";
236 $Shell::POSIX::Select::bad = $Shell::POSIX::Select::do_prompt[2] = 1;
237 }
238 elsif ( $Reply =~ /\D/ ) { # shouldn't be any non-digit!
239 $Shell::POSIX::Select::U_WARN > 0
240 and warn "\tINPUT CONTAINS NON-DIGIT: '$Reply'\n";
241 $Shell::POSIX::Select::bad = 1; # Korn and Bash shell just ignore this case
242 }
243 elsif ( $Reply < 1 or $Reply > $Shell::POSIX::Select::num_values ) {
244 $Shell::POSIX::Select::U_WARN > 0
245 and warn
246 "\t'$Reply' IS NOT IN RANGE: 1 - $Shell::POSIX::Select::num_values\n";
247 $Shell::POSIX::Select::bad = 1; # Korn and Bash shell just ignore this case
248 }
249
250 # warn "BAD is now: $Shell::POSIX::Select::bad";
251 $Shell::POSIX::Select::bad or
252 0 > 2 and warn "About to last out of Reply Validator Loop
253 ";
254 $Shell::POSIX::Select::bad or last; # REPLY VALIDATOR EXITED HERE
255 } # if for validating user input
256 } # infinite while for validating user input
257
258 $_ = $Shell::POSIX::Select::looplist[$Reply - 1]; # set users' variable
259
260 # USER'S LOOP-BLOCK BELOW
261 last LOOP2;;
262
263 # USER'S LOOP-BLOCK ABOVE
264 # Making sure there's colon (maybe
265 # even two) after codestring above,
266 # in case user omitted after last
267 # statement in block. I might add
268 # another statement below it someday!
269 0 > 2 and warn "At end of prompt-repeating loop
270 ";
271 } # infinite while for repeating collection of selections
272 0 and warn "BEYOND end of prompt-repeating loop
273 ";
274 } # endif (defined $Shell::POSIX::Select::menu)
275 else {
276 $Shell::POSIX::Select::DEBUG > 0 and warn "Shell::POSIX::Select: Select Loop #2 has no list, so no iterations\n";
277
278 if ( $Shell::POSIX::Select::dump_data ) {
279 $Reply = undef;
280 # dump filtered source for comparison against expected
281 print STDERR "copacetic
282 "; # ensure some output, and flush pending
283 exit 222; # code for graceful, expected, early exit
284 }
285 }
286 # return omitted above, to get last expression's value
287 # returned automatically, just like shell's version
288
289
290 } # **** END NEW SCOPE FOR SELECTLOOP #2 ****
291 } # **** END WRAPPER SCOPE FOR SELECTLOOP #2 ****
292 # vi:ts=2 sw=2:
293 ;
294
295 # USER'S LOOP-BLOCK ABOVE
296 # Making sure there's colon (maybe
297 # even two) after codestring above,
298 # in case user omitted after last
299 # statement in block. I might add
300 # another statement below it someday!
301 0 > 2 and warn "At end of prompt-repeating loop
302 ";
303 } # infinite while for repeating collection of selections
304 0 and warn "BEYOND end of prompt-repeating loop
305 ";
306 } # endif (defined $Shell::POSIX::Select::menu)
307 else {
308 $Shell::POSIX::Select::DEBUG > 0 and warn "Shell::POSIX::Select: Select Loop #1 has no list, so no iterations\n";
309
310 if ( $Shell::POSIX::Select::dump_data ) {
311 $Reply = undef;
312 # dump filtered source for comparison against expected
313 print STDERR "copacetic
314 "; # ensure some output, and flush pending
315 exit 222; # code for graceful, expected, early exit
316 }
317 }
318 # return omitted above, to get last expression's value
319 # returned automatically, just like shell's version
320
321
322 } # **** END NEW SCOPE FOR SELECTLOOP #1 ****
323 } # **** END WRAPPER SCOPE FOR SELECTLOOP #1 ****
324 # vi:ts=2 sw=2:
325