lib/App/SeismicUnixGui/misc/copyNclean_sgy_up.pl untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 54 CC 2 SCAR 12.0
CC
2
Cov
0%
copy_up
6.0
wanted
2.0
clean
2.0
CRAP 3.3
1 use Moose;
2 =head1 DOCUMENTATION
3  
4 =head2 SYNOPSIS
5  
6 count
7  
8 PERL PROGRAM NAME: copyNclean_sgy_up.pl
9 AUTHOR: Juan Lorenzo
10 DATE: Nov. 23 2023
11  
12 DESCRIPTION
13 Count occurrences of strings in a list
14 Output a new file and filename in one
15 directory above current one, which is usually
16 called "raw"
17
18 Remove beginning zeros and renames
19 "sgy" extension to "segy" extension
20
21 executable shell script exists:
22 copyNclean_segy_up
23  
24 BASED ON:
25  
26 =cut
27  
28 =head2 USE
29  
30 From the command line:
31 copyNclean_segy_up
32  
33 =head3 NOTES
34  
35 =cut
36  
37 my $content_ref = &wanted('./');
38 my @content = @$content_ref;
39  
40 copy_up($content_ref);
41  
42 exit;
43  
44 sub wanted {
45 my ($path2look) = @_;
46  
47 use File::Slurp;
48 my @content = read_dir( $path2look, prefix => 1 );
49  
50 my $result = \@content;
51  
52 return ($result);
53 }
54  
55 =head2 sub clean
56  
57 Removes leading zeros and
58 chages sgy to segy suffix.
59  
60 =cut
61 sub clean {
62 my ($array_ref) = @_;
63 my @names;
64  
65 foreach my $val (@$array_ref) {
66 $val =~ s/^.\/0+//;
67 $val =~ s/sgy/segy/;
68 push @names, $val;
69 }
70 my $result = \@names;
71  
72 return($result);
73 }
74  
75 sub copy_up {
76 my ($array_ref) = @_;
77  
78 my $new_name;
79 my $old_name;
80
81 # pre-condition
82 my @old_name = @$array_ref;
83 print @old_name;
84
85 my $clean_name_aref = &clean($array_ref);
86 my @clean_name = @$clean_name_aref;
87 my $num_names = scalar @clean_name;
88
89 for (my $i=0; $i< $num_names; $i++){
90
91 if ( $old_name[$i] ne './copy.pl'
92 and $old_name[$i] ne '../') {
93  
94 $new_name = "../".$clean_name[$i];
95 system("cp $old_name[$i] $new_name");
96 print ("copy $old_name[$i] $new_name \n");
97 } else {
98 print ("will not cp copy.pl or ../ \n");
99 }
100 }
101  
102 }