in reply to Replacing double spaces (was: Reaplcing double spaces)

In addition to the s/// solution already proposed you can use tr:

my $str = "apple banana lemon"; $str =~ tr/ /|/s; print "$str\n"; # apple|banana|lemon

The /s option to tr is needed to do this. It will make tr "squash" repeated characters generated by transliteration to just one character.