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

Jonathan McKeown jonathan at hst.org.za
Mon Jul 3 07:51:54 PDT 2006


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


More information about the Za-pm mailing list