« lib/App/SeismicUnixGui/misc/big_streams_param.pm
↑ Summary
lib/App/SeismicUnixGui/misc/control.pm »
| 1 | package App::SeismicUnixGui::misc::oop_prog_params; | ||
| 2 | |||
| 3 | =head1 DOCUMENTATION | ||
| 4 | |||
| 5 | |||
| 6 | =head2 SYNOPSIS | ||
| 7 | |||
| 8 | PERL PERL PROGRAM NAME: oop_prog_params | ||
| 9 | AUTHOR: Juan Lorenzo | ||
| 10 | DATE: 2018 | ||
| 11 | |||
| 12 | DESCRIPTION | ||
| 13 | |||
| 14 | |||
| 15 | BASED ON: | ||
| 16 | Version 0.0.2 July 26 2018 | ||
| 17 | changed _private_* to _* | ||
| 18 | removed exceptions to data_in and data_out | ||
| 19 | |||
| 20 | |||
| 21 | =cut | ||
| 22 | |||
| 23 | =head2 USE | ||
| 24 | |||
| 25 | =head3 NOTES | ||
| 26 | |||
| 27 | =head_for_ Examples | ||
| 28 | |||
| 29 | =head2 CHANGES and their DATES | ||
| 30 | |||
| 31 | Version 0.0. _for_ Oct 5, 2018 | ||
| 32 | suffixes and prefixes to program parameter values are allowed | ||
| 33 | by importing the conditions set in each 'program_spec.pm module | ||
| 34 | |||
| 35 | V 0.0.3 September 1 2019 | ||
| 36 | Allows multiple-valued parameters (e.g., curve1, curve2 in suximage) | ||
| 37 | each each with a separate prefix ->label(quotemeta($PREFIX.'/'.$curve1,$PREFIX.'/'.$curve2)); | ||
| 38 | Changes occur in get_a_section | ||
| 39 | Only one suffix and prefix allowed per label | ||
| 40 | |||
| 41 | |||
| 42 | =cut | ||
| 43 | |||
| 44 | use Moose; | ||
| 45 | our $VERSION = '0.0.1'; | ||
| 46 | |||
| 47 | use aliased 'App::SeismicUnixGui::misc::param_sunix'; | ||
| 48 | use App::SeismicUnixGui::misc::control '0.0.3'; | ||
| 49 | use aliased 'App::SeismicUnixGui::misc::control'; | ||
| 50 | use aliased 'App::SeismicUnixGui::misc::L_SU_path'; | ||
| 51 | |||
| 52 | =head2 Instantiation | ||
| 53 | |||
| 54 | =cut | ||
| 55 | |||
| 56 | my $L_SU_path = L_SU_path->new(); | ||
| 57 | |||
| 58 | =head2 program parameters | ||
| 59 | |||
| 60 | private hash | ||
| 61 | |||
| 62 | =cut | ||
| 63 | |||
| 64 | my $oop_prog_params = { | ||
| 65 | _label => '', | ||
| 66 | _prog_name => '', | ||
| 67 | _prog_version => '', | ||
| 68 | _param_labels_aref => '', | ||
| 69 | _param_values_aref => '', | ||
| 70 | }; | ||
| 71 | |||
| 72 | =head2 sub _get_prefix_aref | ||
| 73 | |||
| 74 | obstain prefix values externally for the module | ||
| 75 | MUST first use prefix_aref method to | ||
| 76 | set prefixes internally | ||
| 77 | |||
| 78 | use program_name_spec.pm | ||
| 79 | bring in a different module | ||
| 80 | each program | ||
| 81 | prefix rules are in *_spec.pm | ||
| 82 | prefixes can include a directory path e.g., | ||
| 83 | |||
| 84 | =cut | ||
| 85 | |||
| 86 | sub _get_prefix_aref { | ||
| 87 | |||
| 88 | my ($self) = @_; | ||
| 89 | |||
| 90 | if ( $oop_prog_params->{_prog_name} ) { | ||
| 91 | |||
| 92 | # my $L_SU_global_constants = L_SU_global_constants->new(); | ||
| 93 | my $program_name = $oop_prog_params->{_prog_name}; | ||
| 94 | |||
| 95 | $L_SU_path->set_program_name($program_name); | ||
| 96 | |||
| 97 | my $pathNmodule_spec_w_slash_pm = | ||
| 98 | $L_SU_path->get_pathNmodule_spec_w_slash_pm(); | ||
| 99 | my $pathNmodule_spec_w_colon = | ||
| 100 | $L_SU_path->get_pathNmodule_spec_w_colon(); | ||
| 101 | |||
| 102 | require $pathNmodule_spec_w_slash_pm; | ||
| 103 | |||
| 104 | # INSTANTIATE | ||
| 105 | my $package = $pathNmodule_spec_w_colon->new(); | ||
| 106 | |||
| 107 | $package->binding_index_aref(); | ||
| 108 | $package->prefix_aref(); | ||
| 109 | my $prefix_aref = $package->get_prefix_aref(); | ||
| 110 | |||
| 111 | # print("oop_prog_params,_get_prefix_aref, prefix_aref=@{$prefix_aref} \n"); | ||
| 112 | |||
| 113 | return ($prefix_aref); | ||
| 114 | |||
| 115 | } | ||
| 116 | else { | ||
| 117 | print("oop_prog_params,_get_prefix, missing program name\n"); | ||
| 118 | } | ||
| 119 | |||
| 120 | return (); | ||
| 121 | |||
| 122 | } | ||
| 123 | |||
| 124 | =head2 sub _get_suffix_aref | ||
| 125 | |||
| 126 | use program_name_spec.pm | ||
| 127 | to bring in a different module | ||
| 128 | for each program | ||
| 129 | suffix rules are in *_spec.pm | ||
| 130 | |||
| 131 | bring in suffixes, if they exist | ||
| 132 | |||
| 133 | =cut | ||
| 134 | |||
| 135 | sub _get_suffix_aref { | ||
| 136 | |||
| 137 | my ($self) = @_; | ||
| 138 | |||
| 139 | if ( $oop_prog_params->{_prog_name} ) { | ||
| 140 | |||
| 141 | my $program_name = $oop_prog_params->{_prog_name}; | ||
| 142 | |||
| 143 | $L_SU_path->set_program_name($program_name); | ||
| 144 | |||
| 145 | my $pathNmodule_spec_w_slash_pm = | ||
| 146 | $L_SU_path->get_pathNmodule_spec_w_slash_pm(); | ||
| 147 | my $pathNmodule_spec_w_colon = | ||
| 148 | $L_SU_path->get_pathNmodule_spec_w_colon(); | ||
| 149 | |||
| 150 | require $pathNmodule_spec_w_slash_pm; | ||
| 151 | |||
| 152 | # INSTANTIATE | ||
| 153 | my $package = $pathNmodule_spec_w_colon->new(); | ||
| 154 | |||
| 155 | # set internally and get suffix values externally for the module | ||
| 156 | $package->binding_index_aref(); | ||
| 157 | $package->suffix_aref(); | ||
| 158 | my $suffix_aref = $package->get_suffix_aref(); | ||
| 159 | |||
| 160 | # print("oop_prog_params,_get_suffix_aref, suffixes are: @{$suffix_aref}\n"); | ||
| 161 | return ($suffix_aref); | ||
| 162 | |||
| 163 | } | ||
| 164 | else { | ||
| 165 | print("oop_prog_params,_get_suffix, missing program name\n"); | ||
| 166 | } | ||
| 167 | |||
| 168 | return (); | ||
| 169 | |||
| 170 | } | ||
| 171 | |||
| 172 | =head2 sub _get_prefix_for_a_label | ||
| 173 | |||
| 174 | To place a prefix in front of a sunix parameter | ||
| 175 | for o/p to a perl flow | ||
| 176 | |||
| 177 | =cut | ||
| 178 | |||
| 179 | sub _get_prefix_for_a_label { | ||
| 180 | |||
| 181 | my ($self) = @_; | ||
| 182 | |||
| 183 | my $param_sunix = param_sunix->new(); | ||
| 184 | my $control = control->new(); | ||
| 185 | |||
| 186 | my $prefix = ''; | ||
| 187 | my @all_program_labels; | ||
| 188 | my $labels_aref; | ||
| 189 | my @prefixes; | ||
| 190 | |||
| 191 | # The following must exist | ||
| 192 | my @all_prog_prefixes = @{ _get_prefix_aref() }; | ||
| 193 | my $label = $oop_prog_params->{_label}; | ||
| 194 | my $program_name = $oop_prog_params->{_prog_name}; | ||
| 195 | |||
| 196 | # find all the possible names/labels for this program | ||
| 197 | $param_sunix->set_program_name( \$program_name ); | ||
| 198 | $labels_aref = $param_sunix->get_names(); | ||
| 199 | @all_program_labels = @$labels_aref; | ||
| 200 | |||
| 201 | # number of all possible labels | ||
| 202 | my $length = $param_sunix->get_length4perl_flow(); | ||
| 203 | |||
| 204 | # print("2. oop_prog_params,_get_prefix_for_label, prefix length: $length\n"); | ||
| 205 | # print( | ||
| 206 | # "2. oop_prog_params,_get_prefix_for_label, prefix labels: @all_program_labels\n" | ||
| 207 | # ); | ||
| 208 | |||
| 209 | # what's the index in the configuration file | ||
| 210 | # (not the o/p perl script) | ||
| 211 | # when label names match? | ||
| 212 | for ( my $i = 0 ; $i < $length ; $i++ ) { | ||
| 213 | |||
| 214 | # both labels should contain SOMETHING | ||
| 215 | if ( $label && $all_program_labels[$i] ) { | ||
| 216 | |||
| 217 | # clean the label so that only the last program name is used | ||
| 218 | # e.g., boundary_conditions|abs becomes abs | ||
| 219 | my $clean_config_label = $control->ors( $all_program_labels[$i] ); | ||
| 220 | |||
| 221 | # print( | ||
| 222 | # "oop_prog_params,_get_prefix_for_label, program_name =$program_name\n" | ||
| 223 | # ); | ||
| 224 | # print("2. oop_prog_params,_get_prefix_for_label, label: $label\n"); | ||
| 225 | # print("1. oop_prog_params,_get_prefix_for_label, clean_config_label = $clean_config_label\n"); | ||
| 226 | |||
| 227 | @prefixes = @{ _get_prefix_aref() }; | ||
| 228 | |||
| 229 | # a match locates the index to read from | ||
| 230 | # in the program_spec.pm file | ||
| 231 | if ( $label eq $clean_config_label ) { | ||
| 232 | |||
| 233 | # pick correct prefix | ||
| 234 | $prefix = $prefixes[$i]; | ||
| 235 | |||
| 236 | # print( | ||
| 237 | # "oop_prog_params,_get_prefix_for_label, match i=$i, this label=$label MATCHES $all_program_labels[$i]\n" | ||
| 238 | # ); | ||
| 239 | # print( | ||
| 240 | # "oop_prog_params,_get_prefix_for_label, prefix = $prefix\n" ); | ||
| 241 | |||
| 242 | } | ||
| 243 | else { | ||
| 244 | |||
| 245 | # print("2. oop_prog_params,_get_prefix_for_label: no match NADA \n\n"); | ||
| 246 | # ); | ||
| 247 | } | ||
| 248 | } | ||
| 249 | else { | ||
| 250 | |||
| 251 | # print("2. oop_prog_params,_get_prefix_for_label, this or the other label are empty NADA \n"); | ||
| 252 | } | ||
| 253 | } | ||
| 254 | return ($prefix); | ||
| 255 | } | ||
| 256 | |||
| 257 | sub _get_suffix_for_a_label { | ||
| 258 | my ($self) = @_; | ||
| 259 | |||
| 260 | my $param_sunix = param_sunix->new(); | ||
| 261 | my $control = control->new(); | ||
| 262 | |||
| 263 | my $suffix = ''; | ||
| 264 | my @all_program_labels; | ||
| 265 | my $labels_aref; | ||
| 266 | |||
| 267 | # The following must exist | ||
| 268 | my $label = $oop_prog_params->{_label}; | ||
| 269 | my $program_name = $oop_prog_params->{_prog_name}; | ||
| 270 | |||
| 271 | # find all the available names/labels for this program | ||
| 272 | $param_sunix->set_program_name( \$program_name ); | ||
| 273 | $labels_aref = $param_sunix->get_names(); | ||
| 274 | @all_program_labels = @$labels_aref; | ||
| 275 | |||
| 276 | # number of all possible labels | ||
| 277 | my $length = $param_sunix->get_length4perl_flow(); | ||
| 278 | |||
| 279 | # print("2. oop_prog_params,_get_suffix_for_label, suffix length: $length\n"); | ||
| 280 | # print("2. oop_prog_params, _get_suffix_for_label,suffix labels: @all_program_labels\n"); | ||
| 281 | |||
| 282 | # find index in the configuration file (not the perl script) when label names match | ||
| 283 | for ( my $i = 0 ; $i < $length ; $i++ ) { | ||
| 284 | |||
| 285 | # both labels should contain SOMETHING | ||
| 286 | if ( $label && $all_program_labels[$i] ) { | ||
| 287 | |||
| 288 | # clean the label so that only the last program name is used | ||
| 289 | # e.g., boundary_conditions|abs becomes abs | ||
| 290 | my $clean_config_label = $control->ors( $all_program_labels[$i] ); | ||
| 291 | |||
| 292 | my @suffixes = @{ _get_suffix_aref() }; | ||
| 293 | |||
| 294 | # a match locates the index to read from the program_spec.pm file | ||
| 295 | if ( $label eq $clean_config_label ) { | ||
| 296 | |||
| 297 | $suffix = $suffixes[$i]; | ||
| 298 | |||
| 299 | # print( | ||
| 300 | # "oop_prog_params,_get_suffix_for_label, match i=$i, | ||
| 301 | # this label = $label, this suffix=$suffix\n " | ||
| 302 | # ); | ||
| 303 | |||
| 304 | } | ||
| 305 | else { | ||
| 306 | #NADA print(" 2. oop_prog_params, _get_suffix_for_label, no match \n "); | ||
| 307 | } | ||
| 308 | } | ||
| 309 | else { | ||
| 310 | # print(" 2. oop_prog_params, _get_suffix_for_label this | ||
| 311 | # or the other label are empty \n "); | ||
| 312 | } | ||
| 313 | } | ||
| 314 | |||
| 315 | return ($suffix); | ||
| 316 | } | ||
| 317 | |||
| 318 | sub _set_label_for_a_suffix { | ||
| 319 | my ($label) = @_; | ||
| 320 | |||
| 321 | # needs a program name | ||
| 322 | if ( $label && $oop_prog_params->{_prog_name} ) { | ||
| 323 | |||
| 324 | $oop_prog_params->{_label} = $label; | ||
| 325 | |||
| 326 | # print(" oop_prog_params, _set_label_for_a_suffix, label = $label \n "); | ||
| 327 | |||
| 328 | } | ||
| 329 | else { | ||
| 330 | print( | ||
| 331 | " oop_prog_params, _set_label_for_a_suffix, missing label and /or program name\n" | ||
| 332 | ); | ||
| 333 | } | ||
| 334 | |||
| 335 | return (); | ||
| 336 | } | ||
| 337 | |||
| 338 | =head2 sub _set_label_for_a_prefix | ||
| 339 | |||
| 340 | =cut | ||
| 341 | |||
| 342 | sub _set_label_for_a_prefix { | ||
| 343 | my ($label) = @_; | ||
| 344 | |||
| 345 | # needs a program name | ||
| 346 | if ( $label && $oop_prog_params->{_prog_name} ) { | ||
| 347 | |||
| 348 | $oop_prog_params->{_label} = $label; | ||
| 349 | |||
| 350 | } | ||
| 351 | else { | ||
| 352 | print( | ||
| 353 | "oop_prog_params,_set_label_for_prefix, missing label and/or program name \n " | ||
| 354 | ); | ||
| 355 | } | ||
| 356 | |||
| 357 | return (); | ||
| 358 | } | ||
| 359 | |||
| 360 | =head2 sub get_a_section | ||
| 361 | |||
| 362 | Herein, the output text is assembled | ||
| 363 | |||
| 364 | In order to write the following: | ||
| 365 | e.g., | ||
| 366 | $sugain ->clear(); | ||
| 367 | $sugain ->pbal(1); | ||
| 368 | $sugain[1] = $sugain->Step(); | ||
| 369 | e.g., | ||
| 370 | $suop2 ->clear(); | ||
| 371 | $suop2 ->file1(quotemeta($SEISMIC_PL_SU.'/'.'100_clean'); | ||
| 372 | $suop2 ->op('diff') | ||
| 373 | |||
| 374 | JML 9-1-19 e.g., | ||
| 375 | $suximage ->curvefile(quotemeta($DATA_SEISMIC_TXT.'/'.'curve1,curve2')); | ||
| 376 | |||
| 377 | =cut | ||
| 378 | |||
| 379 | sub get_a_section { | ||
| 380 | my ($self) = @_; | ||
| 381 | |||
| 382 | my $control = control->new(); | ||
| 383 | |||
| 384 | my $prog_name = $oop_prog_params->{_prog_name}; | ||
| 385 | my $j = 0; | ||
| 386 | |||
| 387 | my @oop_prog_params; | ||
| 388 | my $ok = 1; #_get_exceptions(); | ||
| 389 | |||
| 390 | if ($ok) { | ||
| 391 | |||
| 392 | $oop_prog_params[$j] = | ||
| 393 | " \t " . '$' . $prog_name . " \t \t \t \t " . "->clear();"; | ||
| 394 | |||
| 395 | # same as for values | ||
| 396 | my $length = scalar @{ $oop_prog_params->{_param_labels_aref} }; | ||
| 397 | my $version = $oop_prog_params->{_prog_version}; | ||
| 398 | |||
| 399 | for ( | ||
| 400 | my $param_idx = 0, $j = 1 ; | ||
| 401 | $param_idx < $length ; | ||
| 402 | $j++, $param_idx++ | ||
| 403 | ) | ||
| 404 | { | ||
| 405 | |||
| 406 | my $label = @{ $oop_prog_params->{_param_labels_aref} }[$param_idx]; | ||
| 407 | |||
| 408 | # print(" 1. oop_prog_params, get_a_section, label = $label \n "); | ||
| 409 | |||
| 410 | $label = $control->ors($label); | ||
| 411 | |||
| 412 | # print(" 2. oop_prog_params, get_a_section, label = $label \n "); | ||
| 413 | |||
| 414 | my $value = @{ $oop_prog_params->{_param_values_aref} }[$param_idx]; | ||
| 415 | |||
| 416 | # Only, after the label has been cleaned (just above) | ||
| 417 | _set_label_for_a_suffix($label); | ||
| 418 | my $suffix = _get_suffix_for_a_label; | ||
| 419 | |||
| 420 | # print(" 3. oop_prog_params, get_a_section, suffix=$suffix....\n "); | ||
| 421 | |||
| 422 | _set_label_for_a_prefix($label); | ||
| 423 | my $prefix = _get_prefix_for_a_label(); | ||
| 424 | |||
| 425 | # print(" 4. oop_prog_params, get_a_section suffix =$prefix \n "); | ||
| 426 | # $control->set_value($value); | ||
| 427 | # $control->reset_suffix4loop(); | ||
| 428 | # $control->set_suffix4oop($suffix); | ||
| 429 | # $value = $control->get_value4oop(); | ||
| 430 | |||
| 431 | # print(" 4. oop_prog_params, get_a_section value =$value\n "); | ||
| 432 | |||
| 433 | if ( length $prefix && length $suffix ) { | ||
| 434 | |||
| 435 | # print(" 1. oop_prog_params, get_a_section CASE #1 Both suffix and prefix are present\n "); | ||
| 436 | # OUTPUT TEXT is set here | ||
| 437 | $oop_prog_params[$j] = | ||
| 438 | " \t " . '$' | ||
| 439 | . $prog_name | ||
| 440 | . " \t \t \t \t " . '->' | ||
| 441 | . $label | ||
| 442 | . '(quotemeta(' | ||
| 443 | . $prefix | ||
| 444 | . $value . ').' | ||
| 445 | . $suffix . ');'; | ||
| 446 | |||
| 447 | # print(" 1. oop_prog_params, get_a_section CASE #1 OUTPUT TEXT: $oop_prog_params[$j] \n"); | ||
| 448 | # print( | ||
| 449 | # " 1. oop_prog_params, get_a_section CASE #1 suffix=$suffix---prefix=$prefix---value=$value---\n" | ||
| 450 | # ); | ||
| 451 | |||
| 452 | # . '.' | ||
| 453 | } | ||
| 454 | elsif ( !( length($prefix) ) && length($suffix) ) { | ||
| 455 | |||
| 456 | # print(" oop_prog_params, get_a_section CASE #2 No prefix but there is a suffix \n "); | ||
| 457 | # OUTPUT TEXT is set here | ||
| 458 | $oop_prog_params[$j] = | ||
| 459 | " \t " . '$' | ||
| 460 | . $prog_name | ||
| 461 | . " \t \t \t \t " . '->' | ||
| 462 | . $label | ||
| 463 | . '(quotemeta(' | ||
| 464 | . $value | ||
| 465 | . $suffix . '));'; | ||
| 466 | |||
| 467 | } | ||
| 468 | elsif ( $prefix && !($suffix) ) { | ||
| 469 | |||
| 470 | # CASE 3 | ||
| 471 | # print("CASE #3 : oop_prog_params,prefix but no suffix \n"); | ||
| 472 | # OUTPUT TEXT is set here first | ||
| 473 | # First part is: | ||
| 474 | $oop_prog_params[$j] = | ||
| 475 | " \t " . '$' | ||
| 476 | . $prog_name | ||
| 477 | . " \t \t \t \t " . '->' | ||
| 478 | . $label | ||
| 479 | . '(quotemeta('; | ||
| 480 | |||
| 481 | # check for multiple values | ||
| 482 | my $length = scalar $value; | ||
| 483 | |||
| 484 | # print("2. oop_prog_params,get_a,section,value=$value\n"); | ||
| 485 | |||
| 486 | # detect multiple values, if split by comma | ||
| 487 | my @sub_values = split( /,/, $value ); | ||
| 488 | |||
| 489 | # print("oop_prog_params,get_a,section,sub_values:@sub_values\n"); | ||
| 490 | my $num_values = scalar @sub_values; | ||
| 491 | my $last_index = $num_values - 1; | ||
| 492 | |||
| 493 | # print("oop_prog_params,get_a,section,num_values:$num_values\n"); | ||
| 494 | |||
| 495 | if ( defined $num_values | ||
| 496 | && $num_values > 0 ) | ||
| 497 | { # one value must exist | ||
| 498 | |||
| 499 | if ( $num_values >= 2 ) { | ||
| 500 | |||
| 501 | my $control = control->new(); | ||
| 502 | |||
| 503 | # de-tick sub-values for initial case | ||
| 504 | my $i = 0; | ||
| 505 | $control->set_infection( $sub_values[$i] ); | ||
| 506 | $sub_values[$i] = $control->get_ticksBgone(); | ||
| 507 | |||
| 508 | # print("CASE #3A-1: oop_prog_params,get_a,section,de-ticked value:$sub_values[$i]\n"); | ||
| 509 | |||
| 510 | # PREFIX set here | ||
| 511 | # Second part is for initial case: | ||
| 512 | $oop_prog_params[$j] = | ||
| 513 | $oop_prog_params[$j] | ||
| 514 | . $prefix . "'" | ||
| 515 | . $sub_values[$i] . "'" . ".','."; | ||
| 516 | |||
| 517 | # print("CASE #3A-1: oop_prog_params,get_a,section, parts 1-2 is $oop_prog_params[$j]\n"); | ||
| 518 | |||
| 519 | # de-tick sub-values for up-to penultimate case | ||
| 520 | for ( $i = 1 ; $i < ( $num_values - 1 ) ; $i++ ) { | ||
| 521 | |||
| 522 | $control->set_infection( $sub_values[$i] ); | ||
| 523 | $sub_values[$i] = $control->get_ticksBgone(); | ||
| 524 | |||
| 525 | # PREFIX set here | ||
| 526 | # Third part is: | ||
| 527 | $oop_prog_params[$j] = | ||
| 528 | $oop_prog_params[$j] | ||
| 529 | . $prefix . "'" | ||
| 530 | . $sub_values[$i] . "'" . ".','."; | ||
| 531 | |||
| 532 | # print("CASE #3A-2: oop_prog_params,get_a,section, parts 1-r is $oop_prog_params[$j]\n"); | ||
| 533 | |||
| 534 | } | ||
| 535 | |||
| 536 | # de-tick sub-values for last case | ||
| 537 | $control->set_infection( $sub_values[$last_index] ); | ||
| 538 | $sub_values[$last_index] = $control->get_ticksBgone(); | ||
| 539 | |||
| 540 | # Final part has no comma | ||
| 541 | $oop_prog_params[$j] = | ||
| 542 | $oop_prog_params[$j] | ||
| 543 | . $prefix . "'" | ||
| 544 | . $sub_values[$i] . "'" . '));'; | ||
| 545 | |||
| 546 | # print("CASE #3A-3: oop_prog_params,get_a,section,Final part is $oop_prog_params[$j]\n"); | ||
| 547 | |||
| 548 | } | ||
| 549 | elsif ( $num_values == 1 ) { | ||
| 550 | |||
| 551 | # print(" oop_prog_params, get_a_section CASE #3B, single-value case\n "); | ||
| 552 | |||
| 553 | # OUTPUT TEXT is set here | ||
| 554 | # otherwise the prefix is set here , only ONCE | ||
| 555 | $oop_prog_params[$j] = | ||
| 556 | $oop_prog_params[$j] . $prefix . $value . '));'; | ||
| 557 | |||
| 558 | # print("CASE #3B: oop_prog_params,get_a,section,Complete:$oop_prog_params[$j]\n"); | ||
| 559 | |||
| 560 | } | ||
| 561 | else { | ||
| 562 | |||
| 563 | # print("oop_prog_params,get_a,section,NADA\n"); | ||
| 564 | } | ||
| 565 | |||
| 566 | } | ||
| 567 | else { | ||
| 568 | print( | ||
| 569 | "oop_prog_params,get_a,section,strange values, WARNING\n" | ||
| 570 | ); | ||
| 571 | } | ||
| 572 | |||
| 573 | # CASE _for_ | ||
| 574 | } | ||
| 575 | elsif ( $suffix && !($prefix) ) { | ||
| 576 | |||
| 577 | # print(" Case 4 oop_prog_params, get_a_section = suffix but no prefix\n "); | ||
| 578 | # OUTPUT TEXT is set here | ||
| 579 | $oop_prog_params[$j] = | ||
| 580 | " \t " . '$' | ||
| 581 | . $prog_name | ||
| 582 | . " \t \t \t \t " . '->' | ||
| 583 | . $label | ||
| 584 | . '(quotemeta(' | ||
| 585 | . $value | ||
| 586 | . $suffix . '));'; | ||
| 587 | |||
| 588 | } | ||
| 589 | elsif ( !($suffix) && !($prefix) ) { | ||
| 590 | |||
| 591 | # CASE 5 | ||
| 592 | # print(" oop_prog_params, get_a_section = CASE 5; neither suffix nor prefix\n "); | ||
| 593 | # OUTPUT TEXT is set here | ||
| 594 | # $oop_prog_params[$j] = | ||
| 595 | # " \t " . '$' | ||
| 596 | # . $prog_name | ||
| 597 | # . " \t \t \t \t " . '->' | ||
| 598 | # . $label | ||
| 599 | # . '("' | ||
| 600 | # . $value . '");'; | ||
| 601 | |||
| 602 | $oop_prog_params[$j] = | ||
| 603 | " \t " . '$' | ||
| 604 | . $prog_name | ||
| 605 | . " \t \t \t \t " . '->' | ||
| 606 | . $label | ||
| 607 | . '(quotemeta(' | ||
| 608 | . $value . '));'; | ||
| 609 | # print(" oop_prog_params, get_a_section = CASE 5: $oop_prog_params[$j] \n "); | ||
| 610 | } | ||
| 611 | else { | ||
| 612 | |||
| 613 | # CASE 6 | ||
| 614 | print( | ||
| 615 | " oop_prog_params, get_a_section prefix and suffixes are weird \n " | ||
| 616 | ); | ||
| 617 | } | ||
| 618 | |||
| 619 | # print(" 2. oop_prog_params, get_a_section, label, value = $oop_prog_params[$j] \n "); | ||
| 620 | } | ||
| 621 | |||
| 622 | $oop_prog_params[$j] = | ||
| 623 | " \t " . '$' | ||
| 624 | . "$prog_name " . '[' | ||
| 625 | . $version . '] ' | ||
| 626 | . " \t \t \t " . '= $' | ||
| 627 | . "$prog_name " | ||
| 628 | . '->Step();'; | ||
| 629 | return ( \@oop_prog_params ); | ||
| 630 | |||
| 631 | } | ||
| 632 | else { | ||
| 633 | |||
| 634 | # print(" oop_prog_params, get_a_section, data detected \n "); | ||
| 635 | $oop_prog_params[0] = " \t " . 'place data here' . " \n "; | ||
| 636 | return ( \@oop_prog_params ); | ||
| 637 | |||
| 638 | } # no exceptions | ||
| 639 | } | ||
| 640 | |||
| 641 | sub set_many_param_labels { | ||
| 642 | |||
| 643 | my ( $self, $param_labels_href ) = @_; | ||
| 644 | |||
| 645 | if ($param_labels_href) { | ||
| 646 | $oop_prog_params->{_param_labels_aref} = | ||
| 647 | $param_labels_href->{_prog_param_labels_aref}; | ||
| 648 | |||
| 649 | # print(" oop_prog_params, set_param_labels, param_labels, | ||
| 650 | # @{ $oop_prog_params->{_param_labels_aref} } \n "); | ||
| 651 | } | ||
| 652 | return (); | ||
| 653 | } | ||
| 654 | |||
| 655 | sub set_many_param_values { | ||
| 656 | |||
| 657 | my ( $self, $param_values_href ) = @_; | ||
| 658 | |||
| 659 | if ($param_values_href) { | ||
| 660 | $oop_prog_params->{_param_values_aref} = | ||
| 661 | $param_values_href->{_prog_param_values_aref}; | ||
| 662 | |||
| 663 | # print(" oop_prog_params, set_param_values, param_values, | ||
| 664 | # @{ $oop_prog_params->{_param_values_aref} } \n "); | ||
| 665 | } | ||
| 666 | return (); | ||
| 667 | } | ||
| 668 | |||
| 669 | sub set_a_prog_name { | ||
| 670 | |||
| 671 | my ( $self, $prog_name_href ) = @_; | ||
| 672 | |||
| 673 | if ($prog_name_href) { | ||
| 674 | $oop_prog_params->{_prog_name} = $prog_name_href->{_prog_name}; | ||
| 675 | |||
| 676 | # print(" 1. oop_prog_params, set_prog_name, prog_name, | ||
| 677 | # $oop_prog_params->{_prog_name} \n "); | ||
| 678 | } | ||
| 679 | return (); | ||
| 680 | } | ||
| 681 | |||
| 682 | sub set_a_prog_version { | ||
| 683 | |||
| 684 | my ( $self, $prog_version_href ) = @_; | ||
| 685 | |||
| 686 | if ($prog_version_href) { | ||
| 687 | $oop_prog_params->{_prog_version} = $prog_version_href->{_prog_version}; | ||
| 688 | |||
| 689 | # print(" 1. oop_prog_params, set_prog_version, prog_version, | ||
| 690 | # $oop_prog_params->{_prog_version} \n "); | ||
| 691 | } | ||
| 692 | return (); | ||
| 693 | } | ||
| 694 | |||
| 695 | 1; |