Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Replacing whitespaces with a regex

by choroba (Cardinal)
on Mar 04, 2013 at 09:54 UTC ( [id://1021621] : note . print w/replies, xml ) Need Help??


in reply to Replacing whitespaces with a regex

Just do
$words =~ s/\s\s+$/ /;
whithout any if. If there is multiple whitespace, it will be replaced, if not, nothing happens.
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ