in reply to Perl starter with big problem.

You can try this, since your replacement characters are different for each substitution.
#! /usr/bin/perl use strict; my $str='< < PU------------- doc doc S-NN----------- id id S-MN----------- = = X-------------- " " PU-------------'; $str =~ s/\n//g; $str =~ s/\s+/\//g; $str =~ s/(-){2,}/ /g; print "$str\n";