[ale] Perl question

Jerry Yu jjj863 at gmail.com
Thu Apr 12 13:24:34 EDT 2007


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...




More information about the Ale mailing list