Hi,

I'm trying to remove multiple spaces from a string but can't seemed to get it to do what I want without creating a long subroutine.

I have a text file that contains various pieces of data that I want to import. However, there are gaps in between of various sizes. I want to cut them down to 1 space only.

The only way I can see to do this is to create various substituted strings of various lengths to make sure I get them all :

$str =~ s/          / /i;
$str =~ s/         / /i;
$str =~ s/        / /i;
$str =~ s/       / /i;
$str =~ s/      / /i;
$str =~ s/     / /i;
$str =~ s/    / /i;
$str =~ s/   / /i;
$str =~ s/  / /i;

Is there an easier way to do this as I could end up with 48 of these from 2 spaces to 50 spaces?

Cheers!
--
Dale


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to