#/bin/perl/ use strict; use warnings; my $results = "~/results"; my $unpacked = "~/results/unpacked"; my $submit = "~/submit"; my @files; @files = `ls *$txt`; my $filename; my $seq; my $nr; my $mol; my $dir; my $step; my $type; open (my $finished, '>>', "finished.txt"); printf $finished ("%-5s%12s%14s","Molecule","Structure","Step"); printf $finished "\n"; close $finished; foreach (@files) { /(prefix)(_)(\d+)(_)(\d+)(_)(\w+)(_)(\w+)(_)(\w+)(\.)(\w+)/; $filename = "$1$2$3$4$5$6$7$8$9$10$11$12$13"; print "name of file: $filename \n"; print "\n"; $seq= $3; $nr = $5; $mol = $7; $dir = $9; $step = $11; $type = $13; open (my $finished, '>>', "finished.txt"); printf $finished ("%-5s%15s%15s",$mol,$dir,$step); printf $finished "\n"; close $finished; my $check = 0; $check = `ls | grep -c $mol\_$dir\_step\.$out`; print "$mol\_$dir\_$step\.$out: $check \n"; if ($check == 0) { open my $error, '>>', 'error.txt'; print $error "WARNING $mol\_$dir\_$step\.$out is missing \n"; close $error; } else { open my $found, '>>', 'found.txt'; printf $found "$mol\_$dir\_$step\.$out is found \n"; close $found; } $check = 0; print `rsync -ravn \*$mol\_$dir\_$step\.$out ~/results/unpacked/$mol/$dir`; ###this is where my problems start my @step = ( step( 'S', 6, 1, 5 ), ); for $step (@step) { print `touch $step`; } sub step { my ( $name, $total_length, $from, $to ) = @_;# my $length = $total_length - length($name); my $format = "${name}%0${length}d"; return map sprintf( $format, $_ ), $from .. $to; } if (`ls -c *$step*`) { print "$step is found \n" } else { print "$mdstep not found \n" } }