Hopefully :) that may be faster, depending on the size of %file_hash of course.my %file_hash; open my $fh, '<', $fasta_file or die "Cannot open '$fasta_file' $!"; while ( <$fh> ) { my ( $name ) = m!/([^/]+)$!; $name =~ m!((?<=^.{3})\d{4}|(?<=^.{2})\d{8})([FPR])$! or do { print "$name is crap\n"; next; }; $file_hash{ "$1.\L$2" } = $name; } close $fh; open my $qh, '<', $qual_file or die "Cannot open '$qual_file' $!"; while ( my $file = <$qh> ) { chomp $file; next unless $file =~ m!/((?:\d{4}|\d{8})\.[frp])!; if ( exists $file_hash{ $1 } ) { rename $file, "$dir/$file_hash{$1}" or die "Cannot rename '$fi +le' $!"; } else { print "no key $1\n"; } }
In reply to Re: performance problems with renaming multiple files using another file name
by jwkrahn
in thread performance problems with renaming multiple files using another file name
by mav3067
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |