Thanks to all for the input ..<br><br>this is what I ended up with .. that worked ..<br><br>find sub { push(@tmp ,$File::Find::name, &quot;\n&quot;) }, $tmp_dir;<br><br><br>while (&lt;@tmp&gt;){<br>&nbsp;&nbsp;&nbsp; chomp;<br>&nbsp;&nbsp;&nbsp; $_ =~ s/$tmp_dir//;
<br>&nbsp;&nbsp;&nbsp; $_ =~ s/^\///;<br>&nbsp;&nbsp;&nbsp; my $line = $_;<br><br>&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; if( $line =~ /^\+\w+/i ) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print &quot;TO DELETE - $line\n&quot;;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; push(@del_files, $line);<br><br>&nbsp;&nbsp;&nbsp; } else {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( ($line =~ /^\n/) || ($line =~ /tmp\/translate/) || ($line =~ /^\/files/)){ #do nothing
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } else { # add to array<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print &quot;ADD TO file - $line\n&quot;;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; push(@ctr_file , $line);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; } <br>&nbsp;&nbsp;&nbsp; &nbsp;<br>}<br><br><div><span class="gmail_quote">On 6/29/06, <b class="gmail_sendername">
Jonathan McKeown</b> &lt;<a href="mailto:jonathan@hst.org.za">jonathan@hst.org.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;">
On Thursday 29 June 2006 07:37, Gregory Machin wrote:<br><br>&gt; find sub { push(@tmp ,$File::Find::name, -d &amp;&amp; '/', &quot;\n&quot;) }, $tmp_dir;<br>&gt;<br>&gt; #find all files starting with a plus<br>&gt; foreach (@tmp) {
<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; $_ =~ s/$tmp_dir\/// ; # remove the path to the input working dir so<br>&gt; only<br>&gt;&nbsp;&nbsp;&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<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; $_ =~ s/\/$//;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #remove trailing &quot;/&quot;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; # /^\+\w+/i&nbsp;&nbsp;filter all files starting with &quot;+&quot;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; if ($_ =~ /^\+\w+/i ){ push(@del_files, $_); $_ = &quot;0&quot;; } # filter and<br>&gt; pass files starting with + to @del_files for removale
<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; #print &quot;$_&quot;;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; if ($_ ne &quot;0&quot;){<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; push(@ctr_file , &quot;$_&quot;);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;$_&quot;;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt; }<br><br>Nick Cleaton pointed out that in the find line, you're pushing three values
<br>onto the @tmp array for each filename, which accounts for your &quot;\n&quot;s. The<br>middle value is either an empty string, for non-directories, or '/' for<br>directories. / is not the ideal value to have occurring in a list of files
<br>and directories for deletion.<br><br>Depending whether you need the @ctr_files list or not, you might try either<br><br>find sub { push @tmp, $File::Find::name }, $tmp_dir;<br>for my $file (@tmp) {<br>#&nbsp;&nbsp;&nbsp;&nbsp;$file =~ s!^$tmp_dir/!!;
<br>&nbsp;&nbsp;&nbsp;&nbsp;if ($file =~ /^\+/) { push @del_files, $file }<br>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ push @ctr_files, $file }<br>}<br><br>or<br><br>find sub { push @tmp, $File::Find::name }, $tmp_dir;<br>#@tmp = map { s!^$tmp_dir/!! } @tmp;
<br>@del_files = grep { /^\+/ } @tmp;<br><br>The second one doesn't create @ctr_files (obviously). In both cases you can<br>include or leave out the commented line which removes $tmp_dir/ from the<br>start of the full pathname, depending whether you want an absolute or
<br>relative path to the file. (I've used ! as the delimiter in the s/// rather<br>than the usual /, because it saves escaping the / on the end of the dirname.<br>Remember you can use anything as the delimiter for quote-like operators).
<br><br>You've called your arrays @del_files and @ctr_files: they will also contain<br>directories. One way to eliminate all directories from the lists is to change<br>your find line to<br><br>find sub {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $name = $File::Find::name;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;push @tmp, $name unless $name eq $File::Find::dir;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }, $tmp_dir;<br><br>Jonathan<br>_______________________________________________<br>Za-pm mailing list<br><a href="mailto:Za-pm@pm.org">Za-pm@pm.org
</a><br><a href="http://mail.pm.org/mailman/listinfo/za-pm">http://mail.pm.org/mailman/listinfo/za-pm</a><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