lib/App/SeismicUnixGui/developer/code/sunix/update.pm untested

filter: Statementstmt 0.0% 0 / 593 Branchbran 0.0% 0 / 88 Conditioncond 0.0% 0 / 85 MC/DCmcdc 0.0% 0 / 41 Subroutinesub 0.0% 0 / 15 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 829 CC 45 SCAR 48.7
CC
45
Cov
0%
set_changes
272.0
_get_spec_changes
110.0
set_spec_changes
110.0
CRAP 130.4
1 package App::SeismicUnixGui::developer::code::sunix::update;
2  
3 =head1 DOCUMENTATION
4  
5 =head2 SYNOPSIS
6  
7 PROGRAM NAME: update.pm
8  
9 AUTHOR: Juan Lorenzo
10 DATE: September 4 2021 V 0.1
11 DESCRIPTION: minor changes to
12 program_config.pm
13 program_spec.pm
14 and program.pm files
15  
16 =head2 USE
17  
18 =head3 NOTES
19  
20 =head4 Examples
21  
22 =head3 NOTES
23  
24 Program group array and the directory names:
25
26 $developer_sunix_categories[0] = 'data';
27 $developer_sunix_categories[1] = 'datum';
28 $developer_sunix_categories[2] = 'plot';
29 $developer_sunix_categories[3] = 'filter';
30 $developer_sunix_categories[4] = 'header';
31 $developer_sunix_categories[5] = 'inversion';
32 $developer_sunix_categories[6] = 'migration';
33 $developer_sunix_categories[7] = 'model';
34 $developer_sunix_categories[8] = 'NMO_Vel_Stk';
35 $developer_sunix_categories[9] = 'par';
36 $developer_sunix_categories[10] = 'picks';
37 $developer_sunix_categories[11] = 'shapeNcut';
38 $developer_sunix_categories[12] = 'shell';
39 $developer_sunix_categories[13] = 'statsMath';
40 $developer_sunix_categories[14] = 'transform';
41 $developer_sunix_categories[15] = 'well';
42 $developer_sunix_categories[16] = '';
43
44 QUESTION 1:
45 Which group number do you want to use to update
46 for *.pm, *.config, and *_spec.pm files ?
47  
48 e.g., for transforms use:
49 $group_number = 15
50  
51 QUESTION 2:
52 Which program do you want to work on?
53  
54 For example=
55 'sugetgthr';
56 'sugain';
57 'suputgthr';
58 'suifft';
59 'sufctanismod'
60 'vel2stiff
61 'unif2aniso'
62 'transp'
63 'suflip'
64  
65  
66 my $program_name = 'suhistogram';
67  
68 =head2 CHANGES and their DATES
69 Feb. 2022
70 V0.2
71 read a file with spec-file modifications:
72 label_number numbers and suffix_types
73  
74 =cut
75  
76 use Moose;
77 our $VERSION = '0.0.1';
78  
79 =head2 private hash
80  
81 =cut
82  
83 my $update = {
84 _directory => '',
85 _program_name => '',
86 _spec_changes_base_file_name => '',
87 _spec_label_number_aref => '',
88 _spec_suffix_type_aref => '',
89 _group_number => '',
90 _start_binding_index_line => '',
91 _end_binding_index_line => '',
92 _start_file_dialog_type_line => '',
93 _end_file_dialog_type_line => '',
94 _start_prefix_line => '',
95 _end_prefix_line => '',
96 _start_suffix_line => '',
97 _end_suffix_line => '',
98 };
99  
100 =head2 Import packages
101  
102 =cut
103  
104 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
105 use App::SeismicUnixGui::misc::SeismicUnix
106 qw($bin $dat $pl $ps $segb $segd $segy $sgy $su $suffix_bin $suffix_ps
107 $suffix_segy $suffix_sgy $suffix_su $suffix_txt $txt $text);
108 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
109 use aliased 'App::SeismicUnixGui::misc::manage_files_by2';
110 use aliased 'App::SeismicUnixGui::developer::code::sunix::prog_doc2pm';
111 use aliased 'App::SeismicUnixGui::developer::code::sunix::sudoc';
112 use aliased 'App::SeismicUnixGui::developer::code::sunix::sunix_package';
113  
114 =head2 clean memory private hash
115  
116 =cut
117  
118 sub clear {
119  
120 my ($self) = @_;
121  
122 $update->{_directory} = '';
123 $update->{_program_name} = '';
124 $update->{_spec_changes_base_file_name} = '';
125 $update->{_spec_label_number_aref} = '';
126 $update->{_spec_suffix_type_aref} = '';
127 $update->{_group_number} = '';
128 $update->{_start_binding_index_line} = '';
129 $update->{_end_binding_index_line} = '';
130 $update->{_start_file_dialog_type_line} = '';
131 $update->{_end_file_dialog_type_line} = '';
132 $update->{_start_prefix_line} = '';
133 $update->{_end_prefix_line} = '';
134 $update->{_start_suffix_line} = '';
135 $update->{_end_suffix_line} = '';
136  
137 }
138  
139 =head2 sub _get_spec_changes
140  
141 label_number values,
142 directory types
143 suffix types
144  
145 =cut
146  
147 sub _get_spec_changes {
148 my ($self) = @_;
149  
150 if ( length $update->{_program_name} && length $update->{_group_number}
151 and length $update->{_spec_changes_base_file_name} )
152 {
153  
154 my $spec_changes_base_file_name =
155 $update->{_spec_changes_base_file_name};
156  
157 =head2 instantiation of packages
158  
159 =cut
160  
161 my $file = manage_files_by2->new();
162 my $prog_doc2pm = prog_doc2pm->new();
163 my $get = L_SU_global_constants->new();
164  
165 my $var = $get->var();
166 my $on = $var->{_on};
167 my $off = $var->{_off};
168 my $true = $var->{_true};
169 my $false = $var->{_false};
170 my $empty_string = $var->{_empty_string};
171 my $path_in = $prog_doc2pm->get_path_in();
172 my $program_name = $update->{_program_name};
173 my $group_number = $update->{_group_number};
174  
175 =head21 Declare
176  
177 variables
178 =cut
179  
180 my ($directory_type_aref);
181 my ( @directory_type, @prefix_spec, @suffix_spec );
182 $directory_type_aref = \@directory_type;
183 my $inbound =
184 $path_in . '/' . $spec_changes_base_file_name . $suffix_txt;
185  
186 my $spacer = " ";
187 my $aref = $file->read_2cols_aref( $inbound, $spacer );
188 my @array = @$aref;
189 my $label_number_aref = $array[0];
190 my @label_number = @$label_number_aref;
191 my $suffix_type_aref = $array[1];
192 my @suffix_type = @$suffix_type_aref;
193 my $label_number_of = scalar @label_number;
194  
195 for ( my $i = 0 ; $i < $label_number_of ; $i++ ) {
196  
197 # print( "update, _get_spec_changes, $suffix_spec[0] \n");
198 # print( "update, _get_spec_changes, $prefix_spec[0] \n");
199  
200 if ( $suffix_type[$i] eq $bin ) {
201  
202 $prefix_spec[$i] = (" '\$DATA_SEISMIC_BIN' . \".'/'.\";");
203 $suffix_spec[$i] = (" ''.'' . '\$suffix_bin';");
204  
205 }
206 elsif ( $suffix_type[$i] eq $dat ) {
207  
208 $prefix_spec[$i] = (" '\$DATA_SEISMIC_DAT' . \".'/'.\";");
209 $suffix_spec[$i] = (" ''.'' . '\$suffix_dat';");
210  
211 }
212 elsif ( $suffix_type[$i] eq $pl ) {
213  
214 $prefix_spec[$i] = (" '\$PL_SEISMIC' . \".'/'.\";");
215 $suffix_spec[$i] = (" ''.'' . '';");
216  
217 }
218 elsif ( $suffix_type[$i] eq $txt ) {
219  
220 $prefix_spec[$i] = (" '\$DATA_SEISMIC_TXT' . \".'/'.\";");
221 $suffix_spec[$i] = (" ''.'' . '\$suffix_txt';");
222  
223 }
224 elsif ( $suffix_type[$i] eq $text ) {
225  
226 $prefix_spec[$i] = (" '\$DATA_SEISMIC_TXT' . \".'/'.\";");
227 $suffix_spec[$i] = (" ''.'' . '\$suffix_txt';");
228  
229 }
230 elsif ( $suffix_type[$i] eq $segd ) {
231  
232 $prefix_spec[$i] = (" '\$DATA_SEISMIC_SEGD' . \".'/'.\";");
233 $suffix_spec[$i] = (" ''.'' . '\$suffix_segd';");
234  
235 }
236 elsif ($suffix_type[$i] eq $segy
237 || $suffix_type[$i] eq $sgy )
238 {
239  
240 $prefix_spec[$i] = (" '\$DATA_SEISMIC_SEGY' . \".'/'.\";");
241 $suffix_spec[$i] = (" ''.'' . '\$suffix_segy';");
242  
243 }
244 elsif ( $suffix_type[$i] eq $su ) {
245  
246 $prefix_spec[$i] = (" '\$DATA_SEISMIC_SU' . \".'/'.\";");
247 $suffix_spec[$i] = (" ''.'' . '\$suffix_su';");
248  
249 }
250  
251 else {
252 print("update, _get_spec_changes, unexpected variable \n");
253 }
254  
255 }
256  
257 # print( "update, _get_spec_changes, label_number_nos = @label_number, suffixes= @suffix_type \n"
258 # );
259  
260 my $suffix_spec_aref = \@suffix_spec;
261 my $prefix_spec_aref = \@prefix_spec;
262 my @out_array =
263 ( $suffix_spec_aref, $prefix_spec_aref, $label_number_aref );
264 my $result = \@out_array;
265  
266 return ($result);
267  
268 }
269 else {
270 print(
271 "update, _get_spec_changes, missing program name or group number\n"
272 );
273 }
274  
275 return ();
276  
277 }
278  
279 =head2 sub set_program
280  
281 QUESTIONS:
282 Which group number do you want ?
283 What program do you want?
284  
285 =cut
286  
287 sub set_program {
288 my ( $self, $program_name, $group_number ) = @_;
289  
290 print(
291 "update, set_program , group_number category=$group_number, program_name=$program_name\n"
292 );
293  
294 if ( length $program_name
295 && length $group_number )
296 {
297  
298 $update->{_program_name} = $program_name;
299 $update->{_group_number} = $group_number;
300  
301 # print(
302 #"update, set_program, group_number category=$group_number, program_name=$program_name\n"
303 # );
304  
305 }
306 else {
307 print("update, set_program, missing program name or group number\n");
308 }
309  
310 return ();
311  
312 }
313  
314 =head2 sub set_spec_changes
315  
316 label_number values,
317 directory types
318 suffix types
319  
320 =cut
321  
322 sub set_spec_changes {
323 my ($self) = @_;
324  
325 if ( length $update->{_program_name} && length $update->{_group_number}
326 and length $update->{_spec_changes_base_file_name} )
327 {
328  
329 my $sudoc = sudoc->new();
330 my $prog_doc2pm = prog_doc2pm->new();
331  
332 my (@path_in4specs);
333 my ( @spec_file_in, @spec_inbound );
334  
335 my $program_name = $update->{_program_name};
336 my $group_number = $update->{_group_number};
337 $prog_doc2pm->set_group_directory($group_number);
338 $path_in4specs[0] = $prog_doc2pm->get_path_out4specs();
339  
340 =head2 define
341  
342 search lines
343  
344 =cut
345  
346 my ( $start_binding_index_line, $end_binding_index_line );
347 my ( $start_file_dialog_type_line, $end_file_dialog_type_line );
348 my ( $start_prefix_line, $end_prefix_line );
349 my ( $start_suffix_line, $end_suffix_line );
350  
351 my $start_binding_index_line2find = '# e.g., first binding index \(index=0\)';
352 my $end_binding_index_line2find = '= 8; # outbound item is bound';
353 my $end_file_dialog_type_line2find =
354 '# \$type\[\$index\[2\]\] = \$file_dialog_type->\{_Data\};';
355 my $start_file_dialog_type_line2find =
356 '# bound index will look for data';
357 my $start_prefix_line2find = 'sub prefix_aref \{';
358 my $end_prefix_line2find =
359 '\t# label 9 in GUI is input zz_file and needs a home directory';
360 my $end_suffix_line2find =
361 '# \$suffix\[ \$index\[2\] \] = \'\'.\'\' . \'\$suffix_su\';';
362 my $start_suffix_line2find = 'sub suffix_aref \{';
363  
364 =head2 import
365  
366 from program_spec_changes.txt file
367  
368 =cut
369  
370 my $changes_aref = _get_spec_changes();
371 my @changes = @$changes_aref;
372 my $prefix_spec_aref = $changes[1];
373 my $suffix_spec_aref = $changes[0];
374 my $label_number_aref = $changes[2];
375  
376 $spec_file_in[0] = $program_name . '_spec.pm';
377 $spec_inbound[0] = $path_in4specs[0] . '/' . $spec_file_in[0];
378  
379 =head2 Q. What range of lines remain to change in the spec file?
380  
381 Step A: Start by reading in package file (
382 "program"_spec.pm)
383  
384 =cut
385  
386 $sudoc->set_file_in_sref( \$spec_file_in[0] );
387 $sudoc->set_perl_path_in( $path_in4specs[0] );
388  
389 # slurp the whole file
390 $sudoc->whole();
391 my $whole_aref = $sudoc->get_whole();
392  
393 my $length_of_slurp = scalar @{$whole_aref};
394 my @slurp = @{$whole_aref};
395  
396 =head2 STEP B: Follow by finding the following
397  
398 ranges of lines:
399 3)There are lines for prefixes
400 4)There are lines for suffixes
401 1)There are lines where there are interactive label_numbers
402 2) There are lines for data types
403  
404 my $line_range4data_type =
405 my $line_range4prefix =
406 my $line_range4suffix =
407 my $line_range4index =
408  
409 my change4data_standard =
410 my change4prefix_standard =
411 my change4suffix_standard =
412  
413 my $additional_data_change =
414 my $additional_prefix_change =
415 my $additional_suffix_change =
416  
417 =cut
418  
419 for ( my $i = 0 ; $i < $length_of_slurp ; $i++ ) {
420  
421 # print("update,All sunix documentation $slurp[$i]\n");
422  
423 my $string = $slurp[$i];
424  
425 if ( $string =~ /$start_binding_index_line2find/ ) {
426  
427 $start_binding_index_line = $i + 4;
428  
429 # print("update,
430 # a spec success at start_binding_index_line: $start_binding_index_line \n"
431 # );
432 }
433  
434 if ( $string =~ /$end_binding_index_line2find/ ) {
435  
436 $end_binding_index_line = $i + 3;
437  
438 # print("update,
439 # a spec success at end_binding_index_line: $end_binding_index_line \n"
440 # );
441 }
442  
443 if ( $string =~ /$start_file_dialog_type_line2find/ ) {
444  
445 $start_file_dialog_type_line = $i + 2;
446  
447 # print(
448 #"update, a spec success at start_file_dialog_type_line:$start_file_dialog_type_line \n"
449 # );
450 }
451  
452 if ( $string =~ /$end_file_dialog_type_line2find/ ) {
453  
454 $end_file_dialog_type_line = $i + 3;
455  
456 # print(
457 #"update, a spec success at end_file_dialog_type_line:$end_file_dialog_type_line \n"
458 # );
459 }
460 if ( $string =~ /$start_prefix_line2find/ ) {
461  
462 $start_prefix_line = $i + 13;
463  
464 # print(
465 # "update, a spec success at start_prefix_line: $start_prefix_line \n"
466 # );
467 }
468  
469 if ( $string =~ /$end_prefix_line2find/ ) {
470  
471 $end_prefix_line = $i + 3;
472  
473 print(
474 "update, a spec success at end_prefix_line: $end_prefix_line \n"
475 );
476 }
477  
478 if ( $string =~ /$start_suffix_line2find/ ) {
479  
480 $start_suffix_line = $i + 13;
481  
482 # print(
483 # "update, a spec success at start_suffix_line: $start_suffix_line \n"
484 # );
485 }
486  
487 if ( $string =~ /$end_suffix_line2find/ ) {
488  
489 $end_suffix_line = $i + 3;
490  
491 print(
492 "update, a spec success at end_suffix_line:$end_suffix_line \n"
493 );
494 }
495 }
496  
497 my @result = (
498 $start_binding_index_line, $end_binding_index_line,
499 $start_file_dialog_type_line, $end_file_dialog_type_line,
500 $start_prefix_line, $start_suffix_line,
501 $end_suffix_line, $end_prefix_line
502 );
503  
504 $update->{_start_binding_index_line} = $start_binding_index_line;
505 $update->{_end_binding_index_line} = $end_binding_index_line;
506 $update->{_start_file_dialog_type_line} = $start_file_dialog_type_line;
507 $update->{_end_file_dialog_type_line} = $end_file_dialog_type_line;
508 $update->{_start_prefix_line} = $start_prefix_line;
509 $update->{_start_suffix_line} = $start_suffix_line;
510 $update->{_end_suffix_line} = $end_suffix_line;
511 $update->{_end_prefix_line} = $end_prefix_line;
512  
513 return ();
514  
515 }
516 else {
517 print(
518 "update, set_spec_changes, missing program name or group number\n");
519 return ();
520 }
521  
522 }
523  
524 =head2 sub set_spec_changes_base_file_name
525  
526 file name where the following
527 changes can be found:
528 label_number values
529 directory types
530 suffix types
531  
532 =cut
533  
534 sub set_spec_changes_base_file_name {
535 my ( $self, $spec_changes_base_file_name ) = @_;
536  
537 if ( length $update->{_program_name} && length $update->{_group_number}
538 and $spec_changes_base_file_name )
539 {
540  
541 $update->{_spec_changes_base_file_name} = $spec_changes_base_file_name;
542  
543 print(
544 "update, set_spec_changes_base_file_name,spec_changes_base_file_name=$spec_changes_base_file_name\n"
545 );
546  
547 }
548 else {
549 print(
550 "update, set_spec_changes_base_file_name, missing program name or group number\n"
551 );
552 }
553  
554 return ();
555  
556 }
557  
558 sub set_changes {
559  
560 my ($self) = @_;
561  
562 if ( length $update->{_program_name}
563 && length $update->{_group_number} )
564 {
565  
566 my $get = L_SU_global_constants->new();
567 my $sudoc = sudoc->new();
568 my $package = sunix_package->new();
569 my $prog_doc2pm = prog_doc2pm->new();
570  
571 my $var = $get->var();
572 my $true = $var->{_true};
573 my $false = $var->{_false};
574  
575 my (@file_in);
576 my ($i);
577 my @file;
578 my (
579 @path_out4configs, @path_out4developer,
580 @path_out4specs, @path_out4sunix
581 );
582 my (
583 @path_in4configs, @path_in4developer,
584 @path_in4specs, @path_in4sunix
585 );
586 my ( @path_in4global_constants, @path_out4global_constants );
587 my $package_name;
588 my (
589 @config_file_in, @config_file_out, @pm_file_in,
590 @pm_file_out, @spec_file_in, @spec_file_out
591 );
592 my ( @global_constants_file_in, @global_constants_file_out );
593 my (
594 @config_inbound, @config_outbound, @pm_inbound,
595 @pm_outbound, @spec_inbound, @spec_outbound
596 );
597 my ( @global_constants_inbound, @global_constants_outbound );
598 my ( @line_global_constant_success, @line_terminator_success );
599 my $whole_aref;
600 my @slurp;
601 my @program_list;
602 my $max_index;
603 my ( $index_start_extraction, $index_end_extraction );
604 my $length;
605 my $length_of_slurp;
606 my $spec_replacement_success = $false;
607 my $sunix_replacement_success = $false;
608 my $global_constant_success = $false;
609 my $terminator_match_success = $false;
610 my $L_SU_global_constants = 'L_SU_global_constants';
611 my ( $program_name, $group_number );
612  
613 $program_name = $update->{_program_name};
614 $group_number = $update->{_group_number};
615  
616 $prog_doc2pm->set_group_directory($group_number);
617 my @developer_sunix_category =
618 @{ $get->developer_sunix_categories_aref() };
619 my $sunix_category = $developer_sunix_category[$group_number];
620  
621 =head2 private values
622  
623 =cut
624  
625 my $path_in = $prog_doc2pm->get_path_in();
626 my $list_length = $prog_doc2pm->get_list_length();
627  
628 $path_out4developer[0] = $prog_doc2pm->get_path_out4developer();
629  
630 $path_out4configs[0] = $prog_doc2pm->get_path_out4configs();
631 $path_out4specs[0] = $prog_doc2pm->get_path_out4specs();
632 $path_out4sunix[0] = $prog_doc2pm->get_path_out4sunix();
633  
634 $path_in4configs[0] = $prog_doc2pm->get_path_out4configs();
635 $path_in4specs[0] = $prog_doc2pm->get_path_out4specs();
636 $path_in4sunix[0] = $prog_doc2pm->get_path_out4sunix();
637  
638 $path_out4global_constants[0] =
639 $prog_doc2pm->get_path_out4global_constants();
640 $path_in4global_constants[0] =
641 $prog_doc2pm->get_path_out4global_constants();
642  
643 =head2 path definitions
644  
645 =cut
646  
647 $package_name = $program_name;
648 $pm_file_out[0] = $package_name . '.pm';
649 $config_file_out[0] = $package_name . '.config';
650 $spec_file_out[0] = $package_name . '_spec.pm';
651 $global_constants_file_out[0] = $L_SU_global_constants . '.pm';
652  
653 $pm_file_in[0] = $package_name . '.pm';
654 $config_file_in[0] = $package_name . '.config';
655 $spec_file_in[0] = $package_name . '_spec.pm';
656 $global_constants_file_in[0] = $L_SU_global_constants . '.pm';
657  
658 $pm_inbound[0] = $path_in4sunix[0] . '/' . $pm_file_in[0];
659 $config_inbound[0] = $path_in4configs[0] . '/' . $config_file_in[0];
660 $spec_inbound[0] = $path_in4specs[0] . '/' . $spec_file_in[0];
661 $global_constants_inbound[0] =
662 $path_in4global_constants[0] . '/' . $global_constants_file_in[0];
663  
664 $pm_outbound[0] = $path_out4sunix[0] . '/' . $package_name . '.pm';
665 $config_outbound[0] =
666 $path_out4configs[0] . '/' . $package_name . '.config';
667 $spec_outbound[0] =
668 $path_out4specs[0] . '/' . $package_name . '_spec.pm';
669 $global_constants_outbound[0] =
670 $path_out4global_constants[0] . '/' . $global_constants_file_in[0];
671  
672 #$global_constants_outbound[1] = $path_out4global_constants[0] . '/' . $global_constants_file_in[0].'_2';
673  
674 =head2 QUESTION 1:
675  
676 What max_index value do you want to insert?
677 1. Read number of lines in the
678 program_config.pm file
679  
680 slurp config file to get the line number
681 where "max_index" line" is found
682  
683 =cut
684  
685 open( FILE, "< $config_inbound[0]" )
686 or die "can't open $config_inbound[0]: $!";
687 $length_of_slurp++ while <FILE>;
688 close(FILE);
689  
690 # $count now holds the number of lines read
691 print("number of lines read from config_file = $length_of_slurp \n");
692 $max_index = $length_of_slurp - 1;
693  
694 =cut
695  
696 =head3 name definitions
697 for locating lines,
698 word replacements,
699 and "max_index" substitution
700  
701 =cut
702  
703 my $global_constants_string_to_find =
704 ("my \@sunix_$sunix_category\_programs");
705 my $terminator_to_find = '\);';
706  
707 my $spec_string_to_find = 'my \$max_index = # Insert a number here';
708 my $spec_replacement_string =
709 ("my \$max_index = $max_index;");
710  
711 my $sunix_string_to_find = 'my \$max_index = 36;';
712 my $sunix_replacement_string = ("\tmy \$max_index = $max_index;");
713  
714 =head2 Updating spec_files
715  
716 =cut
717  
718 if ( length $package_name
719 && ( -e $spec_inbound[0] )
720 && ( -e $spec_outbound[0] ) )
721 {
722  
723 # print("update, I am in group=$group_number \n");
724 # print("update, I am working on package =$package_name \n");
725 # print("update, updating $spec_file_out[0] in $path_out4specs[0]\n");
726  
727 =head2 Read in package file (
728 "program"_spec.pm)
729  
730 =cut
731  
732 $sudoc->set_file_in_sref( \$spec_file_in[0] );
733 $sudoc->set_perl_path_in( $path_in4specs[0] );
734  
735 # slurp the whole file
736 $sudoc->whole();
737 my $whole_aref = $sudoc->get_whole();
738  
739 my $length_of_slurp = scalar @{$whole_aref};
740  
741 # print("update,num_lines in spec file= $length_of_slurp\n");
742 # for ( my $i = 0; $i < $length_of_slurp; $i++ ) {
743 # print("update,All sunix documentation @{$whole_aref}[$i]\n");
744 # }
745  
746 my @slurp = @{$whole_aref};
747  
748 for ( my $i = 0 ; $i < $length_of_slurp ; $i++ ) {
749  
750 # print("update,All sunix documentation $slurp[$i]\n");
751  
752 my $string = $slurp[$i];
753  
754 # print("update, string to search:$slurp[$i]\n");
755  
756 if ( $string =~ /$spec_string_to_find/ ) {
757  
758 # print("a spec success\n");
759  
760 $slurp[$i] = $spec_replacement_string;
761  
762 print("update, \n $slurp[$i]\n");
763  
764 $spec_replacement_success = $true;
765  
766 }
767  
768 }
769  
770 if ($spec_replacement_success) {
771  
772 # Write out the corrected file
773 print("writing out to $spec_outbound[0]\n");
774  
775 open( OUT, ">$spec_outbound[0]" )
776 or die("File $spec_outbound[0] not found");
777  
778 for ( my $i = 0 ; $i < $length_of_slurp ; $i++ ) {
779  
780 print("$slurp[$i]\n");
781 print OUT $slurp[$i] . "\n";
782  
783 }
784 close(OUT);
785  
786 }
787 else {
788 print("update, spec string replacement unsuccessful\n");
789 }
790 #
791 }
792 else {
793 print "update: a \"spec\" file is missing!\n";
794 } # for a selected program name in the group
795  
796 =head2 Updating sunix.pm files
797  
798 =cut
799  
800 if ( length $package_name
801 && ( -e $pm_outbound[0] )
802 && ( -e $pm_inbound[0] ) )
803 {
804  
805 # print("update, I am in group=$group_number \n");
806 # print("update, I am working on package =$package_name \n");
807 # print("update, updating $pm_file_out[0] in $path_out4sunix[0]\n");
808  
809 =head2 Read in package file (
810 "program".pm)
811  
812 =cut
813  
814 $sudoc->set_file_in_sref( \$pm_file_in[0] );
815 $sudoc->set_perl_path_in( $path_in4sunix[0] );
816  
817 # slurp the whole file
818 $sudoc->whole();
819 my $whole_aref = $sudoc->get_whole();
820  
821 my $length_of_slurp = scalar @{$whole_aref};
822  
823 # print("update.pl,num_lines= $length_of_slurp\n");
824 # for ( my $i = 0; $i < $length_of_slurp; $i++ ) {
825 # print("update,All sunix documentation @{$whole_aref}[$i]\n");
826 # }
827  
828 my @slurp = @{$whole_aref};
829  
830 for ( my $i = 0 ; $i < $length_of_slurp ; $i++ ) {
831  
832 # print ("string to find:$sunix_string_to_find\n");
833 my $string = $slurp[$i];
834  
835 # print("update, string to search:$slurp[$i]\n");
836  
837 if ( $string =~ /$sunix_string_to_find/ ) {
838  
839 # print("a success\n");
840 $sunix_replacement_success = $true;
841 $slurp[$i] = $sunix_replacement_string;
842  
843 }
844  
845 }
846  
847 if ($sunix_replacement_success) {
848  
849 # Write out the corrected file
850 # print("writing out to $pm_outbound[0]\n");
851  
852 open( OUT, ">$pm_outbound[0]" )
853 or die("File $pm_outbound[0] not found");
854  
855 for ( my $i = 0 ; $i < $length_of_slurp ; $i++ ) {
856  
857 # print("$slurp[$i]\n");
858 print OUT $slurp[$i] . "\n";
859  
860 }
861 close(OUT);
862  
863 }
864 else {
865 print("update, sunix string replacement unsuccessful\n");
866 }
867  
868 }
869 else {
870 print "update: an sunix file is missing!\n";
871 } # for a selected program name in the group
872  
873 =head2 update L_SU_global_constants
874  
875 =cut
876  
877 if ( length $package_name
878 && ( -e $global_constants_inbound[0] )
879 && ( -e $global_constants_outbound[0] ) )
880 {
881  
882 # print("update, I am in group=$group_number \n");
883 # print("update, I am working on package =$package_name \n");
884 print(
885 "update, updating $global_constants_file_in[0] in $path_out4global_constants[0]\n"
886 );
887  
888 =head2 Read in file
889 ( L_SU_global_constants.pm )
890  
891 =cut
892  
893 $sudoc->set_file_in_sref( \$global_constants_file_in[0] );
894 $sudoc->set_perl_path_in( $path_in4global_constants[0] );
895  
896 # slurp the whole file
897 $sudoc->whole();
898 $whole_aref = $sudoc->get_whole();
899 @slurp = @{$whole_aref};
900 $length_of_slurp = scalar @{$whole_aref};
901  
902 # print("update.pl,num_lines= $length_of_slurp\n");
903 # for ( my $i = 0; $i < $length_of_slurp; $i++ ) {
904 #
905 # # print("update,All sunix documentation @{$whole_aref}[$i]\n");
906 # }
907  
908 # print("global_constants_string_to_find=$global_constants_string_to_find\n");
909 my @line_success;
910  
911 my $count_global_constant = 0;
912 my $count_terminator = 0;
913  
914 # find the starting expression
915 for ( my $i = 0 ; $i < $length_of_slurp ; $i++ ) {
916  
917 # print("update,$slurp[$i]\n");
918 my $string = $slurp[$i];
919  
920 # print("update, string to search:$slurp[$i]\n");
921  
922 if ( $string =~ /$global_constants_string_to_find/ ) {
923  
924 # print("a success in finding a global constant\n");
925 $line_global_constant_success[$count_global_constant] = $i;
926 $count_global_constant++;
927  
928 # print("update, \n $slurp[$i]\n");
929 $global_constant_success = $true;
930  
931 }
932  
933 # find the tail expression ")"
934 if ( $string =~ /$terminator_to_find/ ) {
935  
936 # print("a success in finding a terminator\n");
937 $line_terminator_success[$count_terminator] = $i;
938 $count_terminator++;
939 $terminator_match_success = $true;
940 }
941  
942 }
943  
944 my $length_line_terminator_success =
945 scalar @line_terminator_success;
946  
947 # print("length_line_terminator_success = $length_line_terminator_success\n");
948 my $length_line_global_constant_success =
949 scalar @line_global_constant_success;
950  
951 # print("length_line_global_constant_success= $length_line_global_constant_success\n");
952  
953 # find difference between start (one) and the tail ")"
954 # expressions (many)
955 if ( $global_constant_success
956 && $terminator_match_success
957 && $count_global_constant == 1 )
958 {
959  
960 my @differences;
961 my $minimum = 1000000; # very large number
962 my $index_of_minimum;
963 for ( my $i = 0 ; $i < $length_line_terminator_success ; $i++ )
964 {
965  
966 $differences[$i] = $line_terminator_success[$i] -
967 $line_global_constant_success[0];
968  
969 # print("update, differences = $differences[$i]\n");
970  
971 }
972  
973 for ( my $i = 0 ; $i < $length_line_terminator_success ; $i++ )
974 {
975  
976 if ( $differences[$i] >= 0 ) {
977  
978 if ( $differences[$i] < $minimum ) {
979  
980 $minimum = $differences[$i];
981 $index_of_minimum = $i;
982  
983 # print("update, minimum = $differences[$i]\n");
984 # print("update, index_of_minimum = $index_of_minimum\n");
985  
986 }
987 }
988  
989 }
990  
991 my $first_index_of_item = $line_global_constant_success[0];
992 my $last_index_of_item = $first_index_of_item + $minimum;
993  
994 # print("update, first_index_of_item= $first_index_of_item\n");
995 # print("update, last_index_of_item= $last_index_of_item\n");
996  
997 # for (my $i=$first_index_of_item; $i <= $last_index_of_item; $i++) {
998 # print("update, sought-after lines=...$slurp[$i]\n");
999 # }
1000  
1001 # extract the lines between the starting and
1002 # ending expressions
1003 $index_start_extraction = $first_index_of_item + 1;
1004 $index_end_extraction = $last_index_of_item - 1;
1005 @program_list =
1006 @slurp[ $index_start_extraction .. $index_end_extraction ];
1007  
1008 # # print("update, program_list= @program_list\n");
1009 # # print( @slurp[$index_start_extraction ..$index_end_extraction]);
1010  
1011 }
1012 else {
1013 print("sudoc2pm, unexpected values \n");
1014 }
1015  
1016 # Remove the inverted commas around the list terms
1017 $length = scalar @program_list;
1018  
1019 for ( my $i = 0 ; $i < $length ; $i++ ) {
1020  
1021 # 1. replace: ",space with a space
1022 $program_list[$i] =~ s/",\s*/\ /g;
1023  
1024 # print("update, item #$i in program_list=....$program_list[$i]\n");
1025  
1026 # remove white space and first "
1027 $program_list[$i] =~ s/"//g;
1028  
1029 #remove first white space
1030 $program_list[$i] =~ s/^\s*//;
1031  
1032 #remove last white space
1033 $program_list[$i] =~ s/\s*$//;
1034  
1035 # remove potential newlines
1036 chomp $program_list[$i];
1037  
1038 # print("update, item #$i in program_list=....$program_list[$i]\n");
1039  
1040 }
1041  
1042 # add a program name to the end of list
1043 push @program_list, $program_name;
1044  
1045 # print("2. update, program_list= @program_list\n");
1046  
1047 # sort alphabetically
1048 @program_list = sort(@program_list);
1049  
1050 # print("3. update, program_list= @program_list\n");
1051  
1052 # prevent duplicates
1053 my @unique = ();
1054 my %seen = ();
1055  
1056 foreach my $elem (@program_list) {
1057  
1058 next if $seen{$elem}++;
1059 push @unique, $elem;
1060 }
1061  
1062 my @new_program_list = @unique;
1063  
1064 $length = scalar @new_program_list;
1065 for ( my $i = 0 ; $i < $length ; $i++ ) {
1066  
1067 # print(
1068 # "4. update, item #$i in program_list=....$program_list[$i]\n"
1069 # );
1070 # add commas and inverted commas again
1071 $new_program_list[$i] =~ s/\ /",\ "/g;
1072  
1073 # put a tab and " at the start of each line
1074 $new_program_list[$i] = "\t\"" . $new_program_list[$i];
1075  
1076 # put a ", at the end of each line
1077 $new_program_list[$i] = $new_program_list[$i] . '",';
1078  
1079 }
1080  
1081 # print("5. update, new_program_list=$new_program_list[0]\n");
1082 # print("5. update, new_program_list=$new_program_list[1]\n");
1083  
1084 # reinsurt new array back into the slurp
1085 # 1. split slurp into 2 arrays
1086 # head array
1087 my @slurp_b4_extraction =
1088 @slurp[ 0 .. ( $index_start_extraction - 1 ) ];
1089  
1090 #tail array
1091 my @slurp_after_extraction =
1092 @slurp[ ( $index_end_extraction + 1 ) .. $length_of_slurp ];
1093  
1094 # print("5.1 update, slurp_b4_extraction: @slurp_b4_extraction\n");
1095  
1096 # add torso to head
1097 push @slurp_b4_extraction, @new_program_list;
1098 my @digested_slurp = @slurp_b4_extraction;
1099  
1100 # print("5.2 update, digested_slurp: @digested_slurp\n");
1101  
1102 # add tail to (torso+head)
1103 push @digested_slurp, @slurp_after_extraction;
1104  
1105 # print("5.3 update, digested_slurp: @digested_slurp\n");
1106  
1107 # Write out the corrected file
1108 # print("writing out to $global_constants_outbound[0] n");
1109 my $length_digested_slurp = scalar @digested_slurp;
1110  
1111 open( OUT, ">$global_constants_outbound[0] " )
1112 or die("File $global_constants_outbound[0] not found");
1113 for ( my $i = 0 ; $i < ( $length_digested_slurp - 1 ) ; $i++ ) {
1114  
1115 if ( $digested_slurp[$i] ne "\t" ) {
1116  
1117 # print(" update,$digested_slurp[$i]\n");
1118 print OUT $digested_slurp[$i] . "\n";
1119 }
1120  
1121 }
1122 close(OUT);
1123 print(" update, wrote out a new $global_constants_file_out[0]\n");
1124  
1125 }
1126 else {
1127 print "update: a global constants file is missing!\n";
1128 } # for a selected global constants file
1129  
1130 }
1131 else {
1132 print("update, missing program name or group number\n");
1133 }
1134  
1135 return ();
1136  
1137 }
1138  
1139 sub spec_changes {
1140  
1141 my ($self) = @_;
1142  
1143 my $changes_aref = _get_spec_changes();
1144  
1145 if ( length $update->{_program_name} && length $update->{_group_number}
1146 and length $update->{_spec_changes_base_file_name}
1147 and length $changes_aref
1148 and length $update->{_start_binding_index_line}
1149 and length $update->{_start_prefix_line}
1150 and length $update->{_start_suffix_line}
1151 and length $update->{_end_suffix_line}
1152 and length $update->{_end_prefix_line} )
1153  
1154 {
1155  
1156 my $sudoc = sudoc->new();
1157 my $prog_doc2pm = prog_doc2pm->new();
1158 my ( @path_in4specs, @path_out4specs );
1159 my ( @spec_file_in, @spec_inbound, @spec_outbound );
1160  
1161 my $program_name = $update->{_program_name};
1162 my $group_number = $update->{_group_number};
1163 $prog_doc2pm->set_group_directory($group_number);
1164 $path_in4specs[0] = $prog_doc2pm->get_path_out4specs();
1165 $path_out4specs[0] = $prog_doc2pm->get_path_out4specs();
1166  
1167 $spec_file_in[0] = $program_name . '_spec.pm';
1168 $spec_inbound[0] = $path_in4specs[0] . '/' . $spec_file_in[0];
1169  
1170 $spec_outbound[0] =
1171 $path_out4specs[0] . '/' . $program_name . '_spec.pm';
1172  
1173 =head3 Read in
1174  
1175 label_number values,
1176 directory types
1177 suffix types
1178  
1179 =cut
1180  
1181 my @changes = @$changes_aref;
1182 my $prefix_spec_aref = $changes[1];
1183 my $suffix_spec_aref = $changes[0];
1184 my $label_number_aref = $changes[2];
1185 my @label = @$label_number_aref;
1186 my $label_number_of = scalar @$label_number_aref;
1187 my @suffix_spec = @$suffix_spec_aref;
1188 my @prefix_spec = @$prefix_spec_aref;
1189 my $line_bump_suffix = 0;
1190 my $line_bump_prefix = 0;
1191 my $line_bump_binding_index = 0;
1192 my $line_bump_file_dialog_type = 0;
1193 my $new_length_of_slurp;
1194  
1195 my ( @temp_array_suffix, @temp_array_prefix );
1196 my ( @temp_array_binding_index, @temp_array_file_dialog_type );
1197  
1198 my $temp_array_length_suffix;
1199 my $temp_array_length_prefix;
1200 my $temp_array_length_binding_index;
1201 my $temp_array_length_file_dialog_type;
1202  
1203 # print("update, spec_changes, suffix_spec:@$suffix_spec_aref\n");
1204 print("update, spec_changes, prefix_spec:@$prefix_spec_aref\n");
1205 print("update, spec_changes, label_number: @$label_number_aref\n");
1206 print("update, spec_changes, label_number_of: $label_number_of\n");
1207  
1208 =head2 Reading in package file (
1209 "program"_spec.pm)
1210  
1211 =cut
1212  
1213 $sudoc->set_file_in_sref( \$spec_file_in[0] );
1214 $sudoc->set_perl_path_in( $path_in4specs[0] );
1215  
1216 # slurp the whole file
1217 $sudoc->whole();
1218 my $whole_aref = $sudoc->get_whole();
1219  
1220 my $length_of_slurp = scalar @{$whole_aref};
1221 my @slurp = @{$whole_aref};
1222  
1223 =head2 include additional lines
1224 that will allow user to interactively
1225 click on the gui and open the
1226 appropraate directory in which to
1227 find a file. These parameters
1228 are written into the program_spec.pm file
1229  
1230 In case new lines are added, keep track
1231 of these lines.
1232  
1233 =cut
1234  
1235 =head2 add to
1236  
1237 suffix_aref lines in *_spec.pm file
1238  
1239  
1240 =cut
1241  
1242 print(
1243 "1. update, spec_changes, start_suffix_line =$update->{_start_suffix_line}\n"
1244 );
1245 print(
1246 "1. update, spec_changes, end_suffix_line =$update->{_end_suffix_line}\n"
1247 );
1248  
1249 my $start_suffix_line = $update->{_start_suffix_line} - 1;
1250 my $end_suffix_line = $update->{_end_suffix_line} - 1;
1251  
1252 =head2 save latter portion for addendum
1253  
1254 to suffix_aref
1255  
1256 =cut
1257  
1258 $temp_array_length_suffix = $length_of_slurp - $end_suffix_line;
1259  
1260 # print("update,spec_changes, length_of_slurp = $length_of_slurp\n");
1261 # print("update,spec_changes, temp_array_length_suffix = $temp_array_length_suffix\n");
1262 @temp_array_suffix[ 0 .. ( $temp_array_length_suffix - 1 ) ] =
1263 @slurp[ $end_suffix_line .. $length_of_slurp ];
1264  
1265 # print("update,spec_changes, temp_array = @temp_array\n");
1266  
1267 =head2 overwrite or add new lines
1268  
1269 to suffix_aref
1270  
1271 =cut
1272  
1273 $slurp[ ($start_suffix_line) ] =
1274 ("\tmy \$index_aref = get_binding_index_aref();");
1275 $slurp[ ( $start_suffix_line + 1 ) ] =
1276 ("\tmy \@index = \@\$index_aref;");
1277  
1278 # recursively modify *_spec.pm file
1279 for ( my $i = 0 ; $i < $label_number_of ; $i++ ) {
1280  
1281 # print("label_number=$label[$i]\n");
1282  
1283 $slurp[ ( $start_suffix_line + ( ( $i + 1 ) * 3 ) ) ] =
1284 (
1285 "\t# label $label[$i] in GUI is input/ouput xx_file and needs a home directory"
1286 );
1287  
1288 $slurp[ ( $start_suffix_line + ( ( $i + 1 ) * 3 ) + 1 ) ] =
1289 ("\t\$suffix[ \$index[$i] ] = $suffix_spec[$i]");
1290  
1291 $slurp[ ( $start_suffix_line + ( ( $i + 1 ) * 3 ) + 2 ) ] = (" ");
1292  
1293 }
1294  
1295 =head2 Add saved text lines
1296  
1297 to suffix_aref
1298 if we have more than 3 input/output interactions
1299  
1300 =cut
1301  
1302 if ( $label_number_of > 3 ) {
1303  
1304 $line_bump_suffix = ( $label_number_of - 3 ) * 3;
1305  
1306 my $new_length_of_slurp = $length_of_slurp + $line_bump_suffix;
1307  
1308 my $new_end_suffix_line = $end_suffix_line + $line_bump_suffix + 1;
1309  
1310 # print(
1311 # "update, spec_changes,new_length_of_slurp=$new_length_of_slurp\n"
1312 # );
1313 # print(
1314 #"update, spec_changes,new_end_suffix_line= $new_end_suffix_line\n"
1315 # );
1316  
1317 @slurp[ ( $new_end_suffix_line - 1 )
1318 .. ( $new_length_of_slurp - 1 ) ] =
1319 @temp_array_suffix[ 0 .. ( $temp_array_length_suffix - 1 ) ];
1320 }
1321 elsif ( $label_number_of <= 3 ) {
1322  
1323 # NADA;
1324 }
1325 else {
1326 print("update, spec_changes, unexpected value \n");
1327 }
1328  
1329 ##########################################################################
1330  
1331 =head2 Add lines to
1332  
1333 prefix_aref lines in *_spec.pm file
1334 Intentionally start from the end of the *.spec file
1335  
1336 =cut
1337  
1338 print(
1339 "update, spec_changes, start_prefix_line =$update->{_start_prefix_line}\n"
1340 );
1341 print(
1342 "1. update, spec_changes, end_prefix_line =$update->{_end_prefix_line}\n"
1343 );
1344 my $start_prefix_line = $update->{_start_prefix_line} - 1;
1345 my $end_prefix_line = $update->{_end_prefix_line} - 1;
1346  
1347 =head2 save latter portion for addendum
1348  
1349 to prefix_aref
1350  
1351 If suffix does not have more than 3 entries the line_bump_* = 0
1352  
1353 =cut
1354  
1355 $new_length_of_slurp = $length_of_slurp + $line_bump_suffix;
1356  
1357 $temp_array_length_prefix = $new_length_of_slurp - $end_prefix_line;
1358  
1359 # print("update,spec_changes, new_length_of_slurp = $new_length_of_slurp\n");
1360 # print("update,spec_changes, prefix_aref temp_array_length_prefix = $temp_array_length_prefix\n");
1361 @temp_array_prefix[ 0 .. ( $temp_array_length_prefix - 1 ) ] =
1362 @slurp[ $end_prefix_line .. $new_length_of_slurp ];
1363  
1364 # print("update,spec_changes, temp_array_prefix = @temp_array_prefix\n");
1365  
1366 $slurp[ ($start_prefix_line) ] =
1367 ("\tmy \$index_aref = get_binding_index_aref();");
1368 $slurp[ ( $start_prefix_line + 1 ) ] =
1369 ("\tmy \@index = \@\$index_aref;");
1370  
1371 # recursively modify *_spec.pm file
1372 for ( my $i = 0 ; $i < $label_number_of ; $i++ ) {
1373  
1374 # print("update, spec_changes, L 1365, label_number=$label[$i]\n");
1375  
1376 $slurp[ ( $start_prefix_line + ( ( $i + 1 ) * 3 ) ) ] =
1377 (
1378 "\t# label $label[$i] in GUI is input/output xx_file and needs a home directory"
1379 );
1380  
1381 $slurp[ ( $start_prefix_line + ( ( $i + 1 ) * 3 ) + 1 ) ] =
1382 ("\t\$prefix[ \$index[$i] ] = $prefix_spec[$i]");
1383  
1384 $slurp[ ( $start_prefix_line + ( ( $i + 1 ) * 3 ) + 2 ) ] =
1385 (" ");
1386  
1387 }
1388  
1389 =head2 Add saved text lines
1390  
1391 to prefix_aref
1392 if we have more than 3 input/output interactions
1393  
1394 =cut
1395  
1396 if ( $label_number_of > 3 ) {
1397  
1398 $line_bump_prefix = ( $label_number_of - 3 ) * 3;
1399  
1400 my $new_length_of_slurp =
1401 $length_of_slurp + $line_bump_suffix + $line_bump_prefix;
1402  
1403 my $new_end_prefix_line = $end_prefix_line + $line_bump_prefix + 1;
1404  
1405 # print(
1406 # "update, spec_changes,new_length_of_slurp, prefix_aref=$new_length_of_slurp\n"
1407 # );
1408 # print(
1409 #"update, spec_changes,new_end_prefix_line= $new_end_prefix_line\n"
1410 # );
1411  
1412 @slurp[ ( $new_end_prefix_line - 1 )
1413 .. ( $new_length_of_slurp - 1 ) ] =
1414 @temp_array_prefix[ 0 .. ( $temp_array_length_prefix - 1 ) ];
1415 }
1416 elsif ( $label_number_of <= 3 ) {
1417  
1418 # NADA;
1419 }
1420 else {
1421 print("update, spec_changes, for prefix_aref unexpected value \n");
1422 }
1423  
1424 ###############################################################################
1425  
1426 =head2 add to
1427  
1428 sub file_dialog_type_aref lines in *_spec.pm file
1429  
1430 =cut
1431  
1432 my $start_file_dialog_type_line =
1433 $update->{_start_file_dialog_type_line};
1434  
1435 my $end_file_dialog_type_line = $update->{_end_file_dialog_type_line};
1436  
1437 print(
1438 "update, spec_changes, start_file_dialog_type_line =$update->{_start_file_dialog_type_line}\n"
1439 );
1440 print(
1441 "update, spec_changes, end_file_dialog_type_line =$update->{_end_file_dialog_type_line}\n"
1442 );
1443  
1444 =head2 Add lines to
1445  
1446 file_dialog_type_aref lines in *_spec.pm file
1447 Intentionally start from the end of the *.spec file
1448  
1449 =cut
1450  
1451 $start_file_dialog_type_line =
1452 $update->{_start_file_dialog_type_line} - 1;
1453 $end_file_dialog_type_line = $update->{_end_file_dialog_type_line};
1454  
1455 =head2 save latter portion for addendum
1456  
1457 to file_dialog_type_aref
1458  
1459 If file_dialog_type does not have more than 3 entries the line_bump_* = 0
1460  
1461 =cut
1462  
1463 $new_length_of_slurp =
1464 $length_of_slurp + $line_bump_suffix + $line_bump_prefix;
1465  
1466 $temp_array_length_file_dialog_type =
1467 $new_length_of_slurp - $end_file_dialog_type_line;
1468 print(
1469 "update,spec_changes, new_length_of_slurp = $new_length_of_slurp\n"
1470 );
1471 print(
1472 "update,spec_changes, file_dialog_type_aref temp_array_length_file_dialog_type = $temp_array_length_file_dialog_type\n"
1473 );
1474 @temp_array_file_dialog_type[ 0 .. (
1475 $temp_array_length_file_dialog_type - 1 ) ] =
1476 @slurp[ $end_file_dialog_type_line .. $new_length_of_slurp ];
1477  
1478 # print("update,spec_changes, temp_array_file_dialog_type = @temp_array_file_dialog_type\n");
1479  
1480 # recursively modify *_spec.pm file
1481 for ( my $i = 0 ; $i < $label_number_of ; $i++ ) {
1482  
1483 # print("update, spec_changes, L 1479, label_number=$label[$i]\n");
1484  
1485 $slurp[ ( $start_file_dialog_type_line + $i ) ] =
1486 ("\t\$type[\$index[$i]] = \$file_dialog_type->\{_Data\};");
1487 }
1488  
1489 =head2 Add saved text lines
1490  
1491 to file_dialog_type_aref
1492 if we have more than 3 input/output interactions
1493  
1494 =cut
1495  
1496 if ( $label_number_of > 5 ) {
1497  
1498 $line_bump_file_dialog_type = ( $label_number_of - 5 );
1499  
1500 my $new_length_of_slurp =
1501 $length_of_slurp +
1502 $line_bump_suffix +
1503 $line_bump_prefix +
1504 $line_bump_file_dialog_type;
1505  
1506 my $new_end_file_dialog_type_line =
1507 $end_file_dialog_type_line + $line_bump_file_dialog_type + 1;
1508  
1509 print(
1510 "update, spec_changes,new_length_of_slurp, file_dialog_type_aref=$new_length_of_slurp\n"
1511 );
1512 print(
1513 "update, spec_changes,new_end_file_dialog_type_line= $new_end_file_dialog_type_line\n"
1514 );
1515  
1516 @slurp[ ( $new_end_file_dialog_type_line - 1 )
1517 .. ( $new_length_of_slurp - 1 ) ] =
1518 @temp_array_file_dialog_type[ 0 .. (
1519 $temp_array_length_file_dialog_type - 1 ) ];
1520 }
1521 elsif ( $label_number_of <= 5 ) {
1522  
1523 # NADA;
1524 }
1525 else {
1526 print(
1527 "update, spec_changes, for file_dialog_type_aref unexpected value \n"
1528 );
1529 }
1530  
1531 #################################################################################
1532  
1533 =head2 add to
1534  
1535 sub binding_index_aref lines in *_spec.pm file
1536  
1537 =cut
1538  
1539 my $start_binding_index_line = $update->{_start_binding_index_line};
1540 my $end_binding_index_line = $update->{_end_binding_index_line};
1541  
1542 print(
1543 "update, spec_changes, start_binding_index_line =$update->{_start_binding_index_line}\n"
1544 );
1545  
1546 print(
1547 "update, spec_changes, end_binding_index_line =$update->{_end_binding_index_line}\n"
1548 );
1549  
1550 =head2 Add lines to
1551  
1552 binding_index_aref lines in *_spec.pm file
1553 Intentionally start from the end of the *.spec file
1554  
1555 =cut
1556  
1557 $start_binding_index_line = $update->{_start_binding_index_line} - 1;
1558 $end_binding_index_line = $update->{_end_binding_index_line} - 1;
1559  
1560 =head2 save latter portion for addendum
1561  
1562 to binding_index_aref
1563  
1564 If file_dialog_type does not have more than 3 entries the line_bump_* = 0
1565  
1566 =cut
1567  
1568 $new_length_of_slurp =
1569 $length_of_slurp +
1570 $line_bump_suffix +
1571 $line_bump_prefix +
1572 $line_bump_file_dialog_type;
1573  
1574 $temp_array_length_binding_index =
1575 $new_length_of_slurp - $end_binding_index_line;
1576 print(
1577 "update,spec_changes, new_length_of_slurp = $new_length_of_slurp\n"
1578 );
1579 print(
1580 "update,spec_changes, binding_index_aref temp_array_length_binding_index = $temp_array_length_binding_index\n"
1581 );
1582 @temp_array_binding_index[ 0 .. ( $temp_array_length_binding_index - 1 )
1583 ] = @slurp[ $end_binding_index_line .. $new_length_of_slurp ];
1584  
1585 # print("update,spec_changes, temp_array_binding_index = @temp_array_binding_index\n");
1586  
1587 # recursively modify *_spec.pm file
1588 for ( my $i = 0 ; $i < $label_number_of ; $i++ ) {
1589  
1590 # print("update, spec_changes, L 1591, label_number=$label[$i]\n");
1591 my $index_out = $label[$i] - 1;
1592 $slurp[ ( $start_binding_index_line + $i ) ] =
1593 ("\t\$index[$i] = $index_out; # inbound/outbound item is bound");
1594 }
1595  
1596 =head2 Add saved text lines
1597  
1598 to binding_index_aref
1599 if we have more than 4 input/output interactions
1600  
1601 =cut
1602  
1603 if ( $label_number_of > 4 ) {
1604  
1605 $line_bump_binding_index = ( $label_number_of - 4 );
1606  
1607 my $new_length_of_slurp =
1608 $length_of_slurp +
1609 $line_bump_suffix +
1610 $line_bump_prefix +
1611 $line_bump_file_dialog_type +
1612 $line_bump_binding_index;
1613  
1614 my $new_end_binding_index_line =
1615 $end_binding_index_line + $line_bump_binding_index + 1;
1616  
1617 print(
1618 "update, spec_changes,new_length_of_slurp, binding_index_aref=$new_length_of_slurp\n"
1619 );
1620 print(
1621 "update, spec_changes,new_end_binding_index_line= $new_end_binding_index_line\n"
1622 );
1623  
1624 @slurp[ ( $new_end_binding_index_line - 1 )
1625 .. ( $new_length_of_slurp - 1 ) ] =
1626 @temp_array_binding_index[ 0 .. (
1627 $temp_array_length_binding_index - 1 ) ];
1628 }
1629 elsif ( $label_number_of <= 4 ) {
1630  
1631 # NADA;
1632 }
1633 else {
1634 print(
1635 "update, spec_changes, for binding_index_aref unexpected value \n"
1636 );
1637 }
1638  
1639 #################################################################################
1640  
1641 =head2 write out
1642  
1643 updated spec file
1644  
1645 =cut
1646  
1647 open( OUT, ">$spec_outbound[0]" )
1648 or die("File $spec_outbound[0] not found");
1649  
1650 $length_of_slurp = scalar @slurp;
1651  
1652 print(
1653 "update,writing out file, spec_changes, length_of_slurp = $length_of_slurp\n"
1654 );
1655  
1656 for ( my $i = 0 ; $i < $length_of_slurp ; $i++ ) {
1657  
1658 # print ("$slurp[$i]\n");
1659 print OUT $slurp[$i] . "\n";
1660  
1661 }
1662 close(OUT);
1663  
1664 }
1665 else {
1666 print("update,spec_changes, a needed variable is missing\n");
1667 print("update,spec_changes,program_name=$update->{_program_name}\n");
1668 print("update,spec_changes,group_number=$update->{_group_number}\n");
1669 print(
1670 "update,spec_changes,spec_changes_base_file_name=$update->{_spec_changes_base_file_name}\n"
1671 );
1672 print("update,spec_changes,$changes_aref=changes_aref\n");
1673 print(
1674 "update,spec_changes,start_binding_index_line=$update->{_start_binding_index_line}\n"
1675 );
1676 print(
1677 "update,spec_changes,start_prefix_line=$update->{_start_prefix_line}\n"
1678 );
1679 print(
1680 "update,spec_changes,start_suffix_line=$update->{_start_suffix_line}\n"
1681 );
1682 print(
1683 "update,spec_changes,end_suffix_line=$update->{_end_suffix_line}\n"
1684 );
1685 print(
1686 "update,spec_changes,end_prefix_line=$update->{_end_prefix_line}\n"
1687 );
1688  
1689 }
1690  
1691 return ();
1692 }
1693  
1694 1;