File: nested_heading_prompt.cdump_ref

package info (click to toggle)
libshell-posix-select-perl 0.09-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 800 kB
  • sloc: perl: 2,727; makefile: 7
file content (333 lines) | stat: -rwxr-xr-x 12,993 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333

$Heading="\n\nQuantity Menu:";
$Prompt="Choose Quantity:";
OUTER:

	# Code generated by Shell::POSIX::Select v0.09, by tim(AT)TeachMePerl.com
	# NOTA BENE: Line 1 of this segment must start with {, so user can LABEL it
  { # **** NEW WRAPPER SCOPE FOR SELECTLOOP #1 ****
		$Shell::POSIX::Select::DEBUG > 1 and 1 == 1 and
			warn "LINE NUMBER FOR START OF USER CODE_BLOCK IS:  ", __LINE__, "\n";
    _SEL_LOOP1: { # **** NEW SCOPE FOR SELECTLOOP #1 ****
	
		# critical for values's contents to be resolved in user's scope
		local @Shell::POSIX::Select::looplist=(1..4);
		local $Shell::POSIX::Select::num_values=@Shell::POSIX::Select::looplist;

		$Shell::POSIX::Select::DEBUG > 4 and do {
			warn "ARRAY VALUES ARE: @Shell::POSIX::Select::looplist\n";
			warn "NUM VALUES is $Shell::POSIX::Select::num_values\n"; 
			warn "user-program debug level is $Shell::POSIX::Select::U_WARN\n"; 
		};
		 my  $quantity;  # LOOP-VAR DECLARATION REQUESTED (perhaps by default)	# loop-var declaration appears here
	
    ;
    local (
			$Shell::POSIX::Select::Prompt[1],
			$Shell::POSIX::Select::menu
				) =
      Shell::POSIX::Select::make_menu(
				$Shell::POSIX::Select::Heading || "",
				$Shell::POSIX::Select::Prompt || "" ,	# Might be overridden in make_menu
				@Shell::POSIX::Select::looplist
			);

	 # no point in prompting a pipe!
		local $Shell::POSIX::Select::do_prompt[1] = (-t) ?  1 : 0 ;
		0 > 2 and warn "do_prompt is $Shell::POSIX::Select::do_prompt[1]\n";
    if ( defined $Shell::POSIX::Select::menu ) {             # No list, no iterations!
      while (1) {    # for repeating prompt for selections
		 # localize, so I don't have to reset  for
		 # outer loop on exit from inner
		 local ($Reply);
        while (1) {    # for validating user's input
          local $Shell::POSIX::Select::bad = 0;

          # local decl suppresses newline on prompt when -l switch turned on
          {
            local $\;
            if ($Shell::POSIX::Select::do_prompt[1]) {

							# When transferring from INNER to OUTER loop,
							# extra NL before prompt is visually desirable

							if ( $Shell::POSIX::Select::_extra_nl) {
								print STDERR "\n\n";
								$Shell::POSIX::Select::_extra_nl=0;
							}
							print STDERR
								"$Shell::POSIX::Select::menu\n$Shell::POSIX::Select::Prompt[1] ";
						}
          }

          #	$Shell::POSIX::Select::do_prompt=0;
					# constant prompting depends on style
          $Shell::POSIX::Select::do_prompt[1]= 0;

          if ( $Shell::POSIX::Select::dump_data ) {
						$Reply = undef;
						# dump filtered source for comparison against expected
						print STDERR "copacetic
";	# ensure some output, and flush pending
						exit 222;	# code for graceful, expected, early exit
					}
          else {
						# $^W=0;
						# warn "Waiting for input";
							$Eof=0;
							$Reply = <STDIN>;
						# warn "Got input";
						# $^W=1;

            if ( !defined( $Reply ) ) {
              defined "" and "" ne "" and print STDERR "";

              # need to undef loop var; user may check it!
              undef $quantity;

              # last Shell::POSIX::Select::_SEL_LOOP1;	# Syntax error!
              # If returning to outer loop, show the prompt for it
              # warn "User hit ^D";
              if ( 1 > 1 and -t ) {    # reset prompting for outer loop
                    $Shell::POSIX::Select::do_prompt[1-1] = 1; $Shell::POSIX::Select::_extra_nl=1;
              }
							0 > 2 and warn "Lasting out of _SEL_LOOP1\n";
							$Eof=1;
              last _SEL_LOOP1;
            }
						!defined $Reply and die "REPLY accessed, while undefined";
            chomp $Reply;

            # undo emboldening of user input
            defined "" and "" ne "" and print STDERR "";

            #print STDERR "$Shell::POSIX::Select::menu\n$Shell::POSIX::Select::Prompt ";
            if ( $Reply eq "" ) {    # interpreted as re-print menu request
                  # Empty input is legit, means redisplay menu
              $Shell::POSIX::Select::U_WARN > 1 and warn "\tINPUT IS: empty\n";
              $Shell::POSIX::Select::bad = $Shell::POSIX::Select::do_prompt[1] = 1;
            }
            elsif ( $Reply =~ /\D/ ) {    # shouldn't be any non-digit!
              $Shell::POSIX::Select::U_WARN > 0
                and warn "\tINPUT CONTAINS NON-DIGIT: '$Reply'\n";
              $Shell::POSIX::Select::bad = 1;    # Korn and Bash shell just ignore this case
            }
            elsif ( $Reply < 1 or $Reply > $Shell::POSIX::Select::num_values ) {
              $Shell::POSIX::Select::U_WARN > 0
                and warn
                "\t'$Reply' IS NOT IN RANGE: 1 - $Shell::POSIX::Select::num_values\n";
              $Shell::POSIX::Select::bad = 1;    # Korn and Bash shell just ignore this case
            }

            # warn "BAD is now: $Shell::POSIX::Select::bad";
             $Shell::POSIX::Select::bad or
							 0 > 2 and warn "About to last out of Reply Validator Loop
";
            $Shell::POSIX::Select::bad or last;    # REPLY VALIDATOR EXITED HERE
          }    # if for validating user input
        }    # infinite while for validating user input

        $quantity = $Shell::POSIX::Select::looplist[$Reply - 1];    # set users' variable

        # USER'S LOOP-BLOCK BELOW
        #	warn "inside Outer loop\n";

	$Heading="\nSize Menu:";
	$Prompt='Choose Size:';
	
	# Code generated by Shell::POSIX::Select v0.09, by tim(AT)TeachMePerl.com
	# NOTA BENE: Line 1 of this segment must start with {, so user can LABEL it
  { # **** NEW WRAPPER SCOPE FOR SELECTLOOP #2 ****
		$Shell::POSIX::Select::DEBUG > 1 and 2 == 1 and
			warn "LINE NUMBER FOR START OF USER CODE_BLOCK IS:  ", __LINE__, "\n";
    _SEL_LOOP2: { # **** NEW SCOPE FOR SELECTLOOP #2 ****
	
		# critical for values's contents to be resolved in user's scope
		local @Shell::POSIX::Select::looplist=( qw (L XL) );
		local $Shell::POSIX::Select::num_values=@Shell::POSIX::Select::looplist;

		$Shell::POSIX::Select::DEBUG > 4 and do {
			warn "ARRAY VALUES ARE: @Shell::POSIX::Select::looplist\n";
			warn "NUM VALUES is $Shell::POSIX::Select::num_values\n"; 
			warn "user-program debug level is $Shell::POSIX::Select::U_WARN\n"; 
		};
		 my  $size;  # LOOP-VAR DECLARATION REQUESTED (perhaps by default)	# loop-var declaration appears here
	
    ;
    local (
			$Shell::POSIX::Select::Prompt[2],
			$Shell::POSIX::Select::menu
				) =
      Shell::POSIX::Select::make_menu(
				$Shell::POSIX::Select::Heading || "",
				$Shell::POSIX::Select::Prompt || "" ,	# Might be overridden in make_menu
				@Shell::POSIX::Select::looplist
			);

	 # no point in prompting a pipe!
		local $Shell::POSIX::Select::do_prompt[2] = (-t) ?  1 : 0 ;
		0 > 2 and warn "do_prompt is $Shell::POSIX::Select::do_prompt[2]\n";
    if ( defined $Shell::POSIX::Select::menu ) {             # No list, no iterations!
      while (1) {    # for repeating prompt for selections
		 # localize, so I don't have to reset  for
		 # outer loop on exit from inner
		 local ($Reply);
        while (1) {    # for validating user's input
          local $Shell::POSIX::Select::bad = 0;

          # local decl suppresses newline on prompt when -l switch turned on
          {
            local $\;
            if ($Shell::POSIX::Select::do_prompt[2]) {

							# When transferring from INNER to OUTER loop,
							# extra NL before prompt is visually desirable

							if ( $Shell::POSIX::Select::_extra_nl) {
								print STDERR "\n\n";
								$Shell::POSIX::Select::_extra_nl=0;
							}
							print STDERR
								"$Shell::POSIX::Select::menu\n$Shell::POSIX::Select::Prompt[2] ";
						}
          }

          #	$Shell::POSIX::Select::do_prompt=0;
					# constant prompting depends on style
          $Shell::POSIX::Select::do_prompt[2]= 0;

          if ( $Shell::POSIX::Select::dump_data ) {
						$Reply = undef;
						# dump filtered source for comparison against expected
						print STDERR "copacetic
";	# ensure some output, and flush pending
						exit 222;	# code for graceful, expected, early exit
					}
          else {
						# $^W=0;
						# warn "Waiting for input";
							$Eof=0;
							$Reply = <STDIN>;
						# warn "Got input";
						# $^W=1;

            if ( !defined( $Reply ) ) {
              defined "" and "" ne "" and print STDERR "";

              # need to undef loop var; user may check it!
              undef $size;

              # last Shell::POSIX::Select::_SEL_LOOP2;	# Syntax error!
              # If returning to outer loop, show the prompt for it
              # warn "User hit ^D";
              if ( 2 > 1 and -t ) {    # reset prompting for outer loop
                    $Shell::POSIX::Select::do_prompt[2-1] = 1; $Shell::POSIX::Select::_extra_nl=1;
              }
							0 > 2 and warn "Lasting out of _SEL_LOOP2\n";
							$Eof=1;
              last _SEL_LOOP2;
            }
						!defined $Reply and die "REPLY accessed, while undefined";
            chomp $Reply;

            # undo emboldening of user input
            defined "" and "" ne "" and print STDERR "";

            #print STDERR "$Shell::POSIX::Select::menu\n$Shell::POSIX::Select::Prompt ";
            if ( $Reply eq "" ) {    # interpreted as re-print menu request
                  # Empty input is legit, means redisplay menu
              $Shell::POSIX::Select::U_WARN > 1 and warn "\tINPUT IS: empty\n";
              $Shell::POSIX::Select::bad = $Shell::POSIX::Select::do_prompt[2] = 1;
            }
            elsif ( $Reply =~ /\D/ ) {    # shouldn't be any non-digit!
              $Shell::POSIX::Select::U_WARN > 0
                and warn "\tINPUT CONTAINS NON-DIGIT: '$Reply'\n";
              $Shell::POSIX::Select::bad = 1;    # Korn and Bash shell just ignore this case
            }
            elsif ( $Reply < 1 or $Reply > $Shell::POSIX::Select::num_values ) {
              $Shell::POSIX::Select::U_WARN > 0
                and warn
                "\t'$Reply' IS NOT IN RANGE: 1 - $Shell::POSIX::Select::num_values\n";
              $Shell::POSIX::Select::bad = 1;    # Korn and Bash shell just ignore this case
            }

            # warn "BAD is now: $Shell::POSIX::Select::bad";
             $Shell::POSIX::Select::bad or
							 0 > 2 and warn "About to last out of Reply Validator Loop
";
            $Shell::POSIX::Select::bad or last;    # REPLY VALIDATOR EXITED HERE
          }    # if for validating user input
        }    # infinite while for validating user input

        $size = $Shell::POSIX::Select::looplist[$Reply - 1];    # set users' variable

        # USER'S LOOP-BLOCK BELOW
        #		warn "inside Inner loop\n";
		print "You chose $quantity units of size $size\n";
		last OUTER;;

        # USER'S LOOP-BLOCK ABOVE
        # Making sure there's colon (maybe
        # even two) after codestring above,
        # in case user omitted after last
        # statement in block. I might add
        # another statement below it someday!
			 0 > 2 and warn "At end of prompt-repeating loop 
";
      }    # infinite while for repeating collection of selections
			0 and warn "BEYOND end of prompt-repeating loop 
";
    }    # endif (defined $Shell::POSIX::Select::menu)
    else {
      $Shell::POSIX::Select::DEBUG > 0 and warn "Shell::POSIX::Select: Select Loop #2 has no list, so no iterations\n";

				if ( $Shell::POSIX::Select::dump_data ) {
					$Reply = undef;
					# dump filtered source for comparison against expected
					print STDERR "copacetic
";	# ensure some output, and flush pending
					exit 222;	# code for graceful, expected, early exit
				}
    }
	# return omitted above, to get last expression's value
	# returned automatically, just like shell's version 

	
	  } # **** END NEW SCOPE FOR SELECTLOOP #2 ****
	} # **** END WRAPPER SCOPE FOR SELECTLOOP #2 ****
	# vi:ts=2 sw=2:
	
#	warn "outside Inner loop\n";;

        # USER'S LOOP-BLOCK ABOVE
        # Making sure there's colon (maybe
        # even two) after codestring above,
        # in case user omitted after last
        # statement in block. I might add
        # another statement below it someday!
			 0 > 2 and warn "At end of prompt-repeating loop 
";
      }    # infinite while for repeating collection of selections
			0 and warn "BEYOND end of prompt-repeating loop 
";
    }    # endif (defined $Shell::POSIX::Select::menu)
    else {
      $Shell::POSIX::Select::DEBUG > 0 and warn "Shell::POSIX::Select: Select Loop #1 has no list, so no iterations\n";

				if ( $Shell::POSIX::Select::dump_data ) {
					$Reply = undef;
					# dump filtered source for comparison against expected
					print STDERR "copacetic
";	# ensure some output, and flush pending
					exit 222;	# code for graceful, expected, early exit
				}
    }
	# return omitted above, to get last expression's value
	# returned automatically, just like shell's version 

	
	  } # **** END NEW SCOPE FOR SELECTLOOP #1 ****
	} # **** END WRAPPER SCOPE FOR SELECTLOOP #1 ****
	# vi:ts=2 sw=2:
	
#warn "outside all loops\n";