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

[MacPerl] more on File globbing



At 12:42 PM 2/19/98 -0500, Chris Nandor wrote:
>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().


Something very odd is going on.

I'm tempted to call it a bug, but I'm far too much an amateur to be
throwing the "b" word around.

At Matthias' suggestion, I tried:

while (glob "$webpath*")
{
	print $_;
}

What I've found is that as long as none of the directories in the path
contain a space, it works.  However, if any contain a space, it fails.

I then went back and tried:

foreach (<$webpath*>)
{
	print $_;
}

and the same thing occured - if there's a space in the path, it fails.

I then tried many combinations of $webpath including:

$webpath="\"Wade'sWorld:Web Pages:Carriers.19.2.1998:\"";

But to no avail.

Am I crazy?  Could it be a bug?

Wade


---------------------------------------------------------------------------
Wade Williams                      "Put your message in a modem, and throw
Systems Engineer, CCIE #3373        it in the cyber sea."
Cisco Systems, Inc.                       - N. Peart
Brentwood, TN                        
615-221-2918                             
wwilliam@cisco.com    
---------------------------------------------------------------------------

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