Debian Codegraph @

Ref_Data/refvar.cdump_ref

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