[ale] Perl question

Christopher Fowler cfowler at outpostsentinel.com
Wed Apr 11 22:06:22 EDT 2007


On Wed, 2007-04-11 at 20:37 -0400, Terry Bailey wrote:
> Hi,
> 
> I want to use a Perl script to remove just the files that end in x, so
> I wrote the following, but it deletes every file in the directory.
> What am I not seeing?   This afternoon, I got tired of using nano and
> started using wordpad.  Do you think there is an embedded character
> that doesn't show?
> 
> 
> 
> 
> 
> 
> $x = "x";
> open(INPIPE, "ls /cygdrive/D/ftproot/abc -1pt | grep -v / |");
> while ($hold = <INPIPE>){
> chomp($hold);
> $tmp = $hold;
> $right = chop($hold);
> if ($x eq $right){system("rm /cygdrive/d/ftproot/abc/$tmp");}
> }
> close(INPIPE);

opendir D, "/cygdrive/D/ftproot/abc";
my @files = readdir D;
closedir D;

foreach (@files) {
  next unless m/x$/;
  unlink "/cygdrive/D/ftproot/abc/$_";
}

> 
> Thanks,
> 
> Terry Bailey
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale




More information about the Ale mailing list