[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ale] Perl question



readdir returns directories as well. unlink could remove a directory named
'blahx', if perl is invoked with '-U' and by super user.
To be safe, a test  or grep needs to be done to get them files only.
Something like  this would work:  my @files = grep  { /x$/ && -f }
readdir(D);

On 4/11/07, Christopher Fowler <cfowler at outpostsentinel.com> wrote:
>
> 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
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>
-------------- next part --------------
An HTML attachment was scrubbed...