use strict; use warnings; my $dir = '.'; # for my $file (glob("$dir/*.seq")) # "glob" is not portable even amoungst *nix systems # and certainly not amoungst Windows systems. opendir(DIR,$dir) or die "unable to open directory $dir:$!"; foreach my $file ( grep{/\.seq$/ && -f $dir/$_}readdir DIR) { my $output_path = "$dir/$file.out"; my $input_path = "$dir/$file"; open (my $in, '<', $input_path) or die "Unable to open $input_path: $!"; open (my $out, '>', $output_path) or die "Unable to open $output_path: $!"; while (<$in>) { s/\^\^/\n^^/g; print $out $_; # oopps ; was missing... } close ($in); close ($out); unlink ($input_path) or die "unable to unlink $input_path: $!"; rename ($output_path, $input_path) or die "Unable to rename $output_path to $input_path:$!"; }