| 1 | package App::SeismicUnixGui::misc::read_psunix; | ||
| 2 | |||
| 3 | =head1 DOCUMENTATION | ||
| 4 | |||
| 5 | |||
| 6 | =head2 SYNOPSIS | ||
| 7 | |||
| 8 | PERL PROGRAM NAME: read_psunix | ||
| 9 | AUTHOR: Juan Lorenzo | ||
| 10 | DATE: June 22 2017 | ||
| 11 | |||
| 12 | DESCRIPTION Parse perl scripts written by L_SU | ||
| 13 | |||
| 14 | |||
| 15 | BASED ON: | ||
| 16 | |||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | =head2 USE | ||
| 21 | |||
| 22 | =head3 NOTES | ||
| 23 | |||
| 24 | =head4 Examples | ||
| 25 | |||
| 26 | |||
| 27 | =head2 CHANGES and their DATES | ||
| 28 | |||
| 29 | |||
| 30 | =cut | ||
| 31 | |||
| 32 | use Moose; | ||
| 33 | our $VERSION = '0.0.1'; | ||
| 34 | use aliased 'App::SeismicUnixGui::misc::sunix_pl'; | ||
| 35 | |||
| 36 | #use write_psunix; | ||
| 37 | |||
| 38 | my @file_in; | ||
| 39 | my @file_out; | ||
| 40 | my $i; | ||
| 41 | my $read_psunix = { | ||
| 42 | |||
| 43 | _all_prog_versions_aref => '', | ||
| 44 | _all_prog_names_aref => '', | ||
| 45 | _good_prog_names_aref => '', | ||
| 46 | _good_prog_versions_aref => '', | ||
| 47 | _labels_aref2 => '', | ||
| 48 | _values_aref2 => '', | ||
| 49 | }; | ||
| 50 | |||
| 51 | $file_in[0] = 'Xamine.pl'; | ||
| 52 | $file_out[0] = 'out.pl'; | ||
| 53 | |||
| 54 | my $sunix_pl = sunix_pl->new(); | ||
| 55 | $sunix_pl->set_file_in( \@file_in ); | ||
| 56 | $sunix_pl->set_file_out( \@file_out ); | ||
| 57 | |||
| 58 | =pod | ||
| 59 | |||
| 60 | read perl file line by line | ||
| 61 | $sunix_pl->get_good_sunix_names(); # always AFTER get_good_sunix_params | ||
| 62 | |||
| 63 | =cut | ||
| 64 | |||
| 65 | $sunix_pl->whole(); | ||
| 66 | $sunix_pl->set_progs_start_with('clear'); | ||
| 67 | $sunix_pl->set_progs_end_with('Step()'); | ||
| 68 | $sunix_pl->set_num_progs(); | ||
| 69 | $read_psunix->{_all_prog_names_aref} = $sunix_pl->get_all_sunix_names(); | ||
| 70 | $read_psunix->{_all_prog_versions_aref} = $sunix_pl->get_all_versions(); | ||
| 71 | |||
| 72 | my $length = $sunix_pl->get_num_progs; | ||
| 73 | |||
| 74 | my $hash_ref = $sunix_pl->get_good_sunix_params(); | ||
| 75 | $read_psunix->{_good_prog_names_aref} = $sunix_pl->get_good_sunix_names(); | ||
| 76 | $read_psunix->{_good_prog_versions_aref} = $sunix_pl->get_good_prog_versions(); | ||
| 77 | |||
| 78 | print("main,all prog versions: @{$read_psunix->{_all_prog_versions_aref}}\n"); | ||
| 79 | print("main,all program names: @{$read_psunix->{_all_prog_names_aref}}\n"); | ||
| 80 | print("main, $length programs have been found in $file_in[0]\n"); | ||
| 81 | print("main,good program names: @{$read_psunix->{_good_prog_names_aref}}\n"); | ||
| 82 | print( | ||
| 83 | "main,good program versions: @{$read_psunix->{_good_prog_versions_aref}}\n" | ||
| 84 | ); | ||
| 85 | |||
| 86 | $read_psunix->{_labels_aref2} = $hash_ref->{_labels_aref2}; | ||
| 87 | $read_psunix->{_values_aref2} = $hash_ref->{_values_aref2}; | ||
| 88 | |||
| 89 | my $new_num_progs = sunix_pl->get_num_good_progs(); | ||
| 90 | print("main,o/p num_progs: $new_num_progs\n"); | ||
| 91 | |||
| 92 | for ( my $i = 0 ; $i < $new_num_progs ; $i++ ) { | ||
| 93 | |||
| 94 | my $num_params = scalar @{ @{ $read_psunix->{_values_aref2} }[$i] }; | ||
| 95 | my @good_prog_names = @{ $read_psunix->{_good_prog_names_aref} }; | ||
| 96 | my $good_prog_name = $good_prog_names[$i]; | ||
| 97 | my @good_prog_versions = @{ $read_psunix->{_good_prog_versions_aref} }; | ||
| 98 | my $good_prog_version = $good_prog_versions[$i]; | ||
| 99 | |||
| 100 | print("main,good_prog_name: $good_prog_name\n"); | ||
| 101 | print("main,good_prog_version: $good_prog_version\n"); | ||
| 102 | |||
| 103 | for ( my $j = 0 ; $j < $num_params ; $j++ ) { | ||
| 104 | |||
| 105 | my @labels = @{ @{ $read_psunix->{_labels_aref2} }[$i] }; | ||
| 106 | my @values = @{ @{ $read_psunix->{_values_aref2} }[$i] }; | ||
| 107 | my $label = $labels[$j]; | ||
| 108 | my $value = $values[$j]; | ||
| 109 | |||
| 110 | print("sunix_pl,get_good_sunix_params,label: $label\n"); | ||
| 111 | print("sunix_pl,get_good_sunix_params,value: $value\n"); | ||
| 112 | } | ||
| 113 | } | ||
| 114 |