thanks for the alternative methode.<br><br>but why does this not work&nbsp; .....<br>if ($_ =~ /^\+\w+/i ){ push(@del_files, $_); $_ = &quot;0&quot;; } # filter and pass files starting with + to @del_files for removale<br>&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; #print &quot;$_&quot;;<br>&nbsp;&nbsp;&nbsp; if ($_ ne &quot;0&quot;){&nbsp; &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; why is this logic still creating &quot;\ n&quot; in the array .. it should only append to the array if $_ holds a valid path.
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; push(@ctr_file , &quot;$_&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print &quot;$_&quot;;<br>&nbsp;&nbsp;&nbsp; }<br><br><div><span class="gmail_quote">On 6/29/06, <b class="gmail_sendername">Spike</b> &lt;<a href="mailto:spikeh@mweb.co.za">spikeh@mweb.co.za
</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>
<div>
So many ways to do the same thing in perl!<br><br>
I would probably have gone:-<br><br>
<tt>&nbsp; opendir (DIR, &quot;$my_directory&quot;)<br>
&nbsp;&nbsp;&nbsp; or die(&quot;could not open DIR as $my_directory
Error: $!&quot;);<br><br>
&nbsp; @dir = readdir DIR;<br><br>
&nbsp; foreach (@dir)<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; chomp;<br><br>
&nbsp;&nbsp;&nbsp; if (m/^\+\w/)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; push (@del_files, $_);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; push (@ctr_file, $_);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp; }<br><br>
&nbsp; foreach (del_files)<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; unlink ($my_director/$_) or die(&quot;unlink failed
$!);<br>
&nbsp; }<br><br>
# assuming a unix type OS; I have often found that file manipulation is
one of the few places where a system call directly to the underlining OS
commands is better than the PERL commands. So maybe:-<br><br>
&nbsp; foreach (del_files)<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; $status = system(&quot;rm -f
$my_director/$_&quot;);<br>
&nbsp;&nbsp;&nbsp; die unless $status == 0;<br>
&nbsp; }<br><br>
<br><br>
<br><br>
<br>
</tt></div><div><span class="e" id="q_10c1e6b417001ed0_1">At 2006/06/29 07:37 AM, you wrote:<br>
</span></div><div><blockquote type="cite" cite="http://"></blockquote></div><div><span class="e" id="q_10c1e6b417001ed0_3">Hi<br>
I have been writing a script to pass a directory the remove all the files
starting with &quot;+&quot; and put them in a&nbsp; an array @del_files
and all the remaining in an array @ctr_file<br>
The problem Im having is that where the +FILE 's used to be I get blank
lines with &quot;\n&quot;&nbsp; in the @ctr_file, which I don't want .
<br><br>
find sub { push(@tmp
,$<a>File::Find::name</a>, -d
&amp;&amp; '/', &quot;\n&quot;) }, $tmp_dir;<br><br>
#find all files starting with a plus<br>
foreach (@tmp) {<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; $_ =~ s/$tmp_dir\/// ; # remove the path to the input
working dir so only <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
# the files and directories in the working dir are used&nbsp; <br>
&nbsp;&nbsp;&nbsp; $_ =~
s/\/$//;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #remove trailing
&quot;/&quot;<br>
&nbsp;&nbsp;&nbsp; # /^\+\w+/i&nbsp; filter all files starting with
&quot;+&quot; <br>
&nbsp;&nbsp;&nbsp; if ($_ =~ /^\+\w+/i ){ push(@del_files, $_); $_ =
&quot;0&quot;; } # filter and pass files starting with + to @del_files
for removale <br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; #print &quot;$_&quot;;<br>
&nbsp;&nbsp;&nbsp; if ($_ ne &quot;0&quot;){<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; push(@ctr_file ,
&quot;$_&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;$_&quot;;<br>
&nbsp;&nbsp;&nbsp; }<br>
}<br><br>
<br>
Many thanks for you time<br>
Greg<br></span></div><div>
_______________________________________________<br>
Za-pm mailing list<br>
<a href="mailto:Za-pm@pm.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Za-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/za-pm" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://mail.pm.org/mailman/listinfo/za-pm</a></div>


</div><br>_______________________________________________<br>Za-pm mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Za-pm@pm.org">Za-pm@pm.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://mail.pm.org/mailman/listinfo/za-pm" target="_blank">
http://mail.pm.org/mailman/listinfo/za-pm</a><br><br></blockquote></div><br><br clear="all"><br>-- <br>Gregory Machin<br><a href="mailto:greg@linuxpro.co.za">greg@linuxpro.co.za</a><br><a href="mailto:gregory.machin@gmail.com">
gregory.machin@gmail.com</a><br><a href="http://www.linuxpro.co.za">www.linuxpro.co.za</a><br><a href="http://www.exponent.co.za">www.exponent.co.za</a><br>Web Hosting Solutions<br>Scalable Linux Solutions <br><a href="http://www.iberry.info">
www.iberry.info</a> (support and admin)<br><br>+27 72 524 8096