note
BrowserUk
<blockquote><i>I want to remove one of those spaces (so I can 'split()' the line on spaces consistantly)</i></blockquote>
<p>Seems like your working hard to do something that can be far more easily achieved.
<P>The problem you are trying to fix is when you [split] on \s. (Here I've substituted _ for spaces to make things clearer.):<code>
$s = 'The_quick__brown____fox';;
print for split /_/, $s;;
The
quick
brown
fox
</code>
<p>Instead of trying to remove the extra spaces, simply accommodate them:<code>
print for split /_+/, $s;;
The
quick
brown
fox
</code>
<P>Problem solved.
<p>In addition, as splitting on variable amounts of whitespace is such a common thing to do, if you supply [split] with a single space (<c>' '</c>) in place of the regex argument, it takes care of that (and any leading whitespace) for you:<code>
print for split / /, ' the quick brown fox ';;
the
quick
brown
fox
print for split ' ', ' the quick brown fox ';;
the
quick
brown
fox
</code>
<div class="pmsig"><div class="pmsig-171588">
<hr />
<font size=1 >
<div>With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'</div>
<div>Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.</div>
<div>"Science is about questioning the status quo. Questioning authority". </div>
<div>In the absence of evidence, opinion is indistinguishable from prejudice.
</div>
</font>
</div></div>
1016574
1016574