#!usr/bin/perl my $FILENAME4 = "organized.txt"; open(DATA2, $FILENAME4); #remove all previous re-organized files my $remove_reorganized = "re-organized.txt"; if (unlink($remove_reorganized) == 1) { print "Existing \"re-organized.txt\" file was removed\n"; } #now make a file for the ouput my $outputfile = "re-organized.txt"; if (! open(POS, ">>$outputfile") ) { print "Cannot open file \"$outputfile\" to write to!!\n\n"; exit; } while (my $organized = ) { #do some re-organizing #sort out the group numbers first $organized =~ s/(\w+)[^(^\d+)(\s)]/z/g; my $organized2 = $organized; $organized2 =~ s/z(\d+)/z/g; print POS $organized2; }