$expression =~ s/(\s)\s+/\1/gs<br><br>that replaces sequences of two or more \s with one of whatever the first one matched.<br>note that mixed tabs and blanks will get replaced.<br><br>if you just want replacement of pure strings of a particular character ...<br>
<br>$expression =~ s/(\s)\1+/\1/gs<br><br>this will replace strings of blanks with a single blank, but if the blanks and tabs alternate it will do nothing with it.<br><br>if you load $expression with multiple lines, this should also reduce multiple lines to one.  don't try this on windows files though.<br>
<br>cheers,<br>Rob<br><br><div class="gmail_quote">On Sat, Oct 27, 2012 at 6:19 PM, Chris Jones <span dir="ltr"><<a href="mailto:cj@enersave.ca" target="_blank">cj@enersave.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thank Stuart, I did end up using $File::Find::dir, very helpful.<br>
<br>
New question.  I would like to replace multiple spaces with single spaces and multiple end of line  with a single end of line.<br>
<br>
I thought this might work:<br>
$expression =~ s/(\s+)/\1/g; # puts back what it found<br>
<br>
So I tried<br>
$expression =~ s/(\s)/\1\s/g;<br>
That gave me the original double white space plus an s.<br>
<br>
Any insight very much appreciated.<br>
<br>
<br>
But that replaces all white spaces with<br>
At 07:55 PM 23/10/2012, Stuart Watt wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 2012-10-23, at 2:32 PM, Chris Jones <<a href="mailto:cj@enersave.ca" target="_blank">cj@enersave.ca</a>> wrote:<br>
<br>
> My tests are working correctly, I don't try to delete directories.<br>
><br>
> My follow on question is how do you tell File:Find to skip the directory the script is called from.  I only want to delete files in the sub-directories.<br>
><br>
> I can test each file to see if it's directory is '.' but would seem somewhat inefficient?<br>
<br>
String matching efficiency is probably a thousand times higher than file system accesses, so if I was you I really wouldn't worry about it. I tend to use no_chdir => 1 and $File::Find::name, but to skip everything in the base directory, probably checking to see if $File::Find::dir is the same as the base should be quick and effective.<br>

<br>
All the best<br>
Stuart<br>
______________________________<u></u>_________________<br>
</blockquote>
<br>
>><br>
Christopher Jones, P.Eng.<br>
Suite 1801, 1 Yonge Street<br>
Toronto, ON M5E1W7<br>
Tel. <a href="tel:416-203-7465" value="+14162037465" target="_blank">416-203-7465</a><br>
Fax. <a href="tel:416-946-1005" value="+14169461005" target="_blank">416-946-1005</a><br>
email <a href="mailto:cj@enersave.ca" target="_blank">cj@enersave.ca</a><br>
<br>
______________________________<u></u>_________________<br>
toronto-pm mailing list<br>
<a href="mailto:toronto-pm@pm.org" target="_blank">toronto-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/toronto-pm" target="_blank">http://mail.pm.org/mailman/<u></u>listinfo/toronto-pm</a><br>
</blockquote></div><br>