[Za-pm] loop adding \n to array ??

Spike spikeh at mweb.co.za
Tue Jul 4 00:01:08 PDT 2006


how about :-

find /dir_to_search  -maxdepth 1 -name '+*' -exec rm {} \;

... only joking!




At 2006/07/03 04:51 PM, Jonathan McKeown wrote:
>On Monday 03 July 2006 15:56, Gregory Machin wrote:
> > Thanks to all for the input ..
> >
> > this is what I ended up with .. that worked ..
> >
> > find sub { push(@tmp ,$File::Find::name, "\n") }, $tmp_dir;
> >
> >
> > while (<@tmp>){
> >     chomp;
> >     $_ =~ s/$tmp_dir//;
> >     $_ =~ s/^\///;
> >     my $line = $_;
> >
> >
> >     if( $line =~ /^\+\w+/i ) {
> >         print "TO DELETE - $line\n";
> >         push(@del_files, $line);
> >
> >     } else {
> >         if ( ($line =~ /^\n/) || ($line =~ /tmp\/translate/) || ($line =~
> > /^\/files/)){ #do nothing
> >         } else { # add to array
> >         print "ADD TO file - $line\n";
> >         push(@ctr_file , $line);
> >         }
> >     }
> >
> > }
>
>This still looks very complicated: you're still pushing the "\n" onto @tmp in
>the find sub - and then taking it out again in the if-clause marked with the
>comment #do nothing.
>
>It also doesn't work for me. What's the intention of the line
>while (<@tmp>) {
>?
>
>Jonathan
>_______________________________________________
>Za-pm mailing list
>Za-pm at pm.org
>http://mail.pm.org/mailman/listinfo/za-pm



More information about the Za-pm mailing list