Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Replacing whitespaces with a regex

by Enlil (Parson)
on Mar 04, 2013 at 10:15 UTC ( [id://1021622] : note . print w/replies, xml ) Need Help??


in reply to Replacing whitespaces with a regex

for ( @array ) { s/\s\s+$/ / }
or
s/\s\s+$/ / for @array;
since essentially you are testing all the words to see if they fit the pattern anyhow.