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

Re: [MacPerl] File globbing



At 12.14 1998.02.19, Wade Williams wrote:
>Hmm, I must be doing something stupid:
>
>$webpath="Wade'sWorld:Web Pages:Carriers.19.2.1998:";
>$shortpath=$webpath;
>chop($shortpath);
>
>if (-e $shortpath)
>{
>    foreach(<$webpath*>)
>    {
>       unlink($_);
>    }
>    rmdir($shortpath);
>}
>mkdir($shortpath,0775);
>
>This code fails to remove any files from the directory specified by
>$webpath.  The path is correct, the directory exists, and the directory has
>files in it.  It simply evaluates the foreach line, and moves onto the
>rmdir line (which of course fails since files still exist).

1.  Check for errors: unlink($_) || die #!;
2.  Check filename:   print $_, "\n";

That will likley give you your answer.  If not, let us know.

Also don't forget to check for errors with rmdir() and mkdir().

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==               New Book:  MacPerl: Power and Ease               ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch