On Thu, Aug 07, 2003 at 11:00:07PM -0400, perlwannabe wrote:
> > Steve Grazzini wrote at Wed, 06 Aug 2003 23:38:00 -0400:
> >>   my $pat = 'c:\testdir\*030977*.*';
                            ^

That looks like trouble. Using forward slashes, as Janek has
done below, would have been smarter.

> >>   foreach (glob($pat)) {
> >>       unlink or warn "Couldn't unlink '$_': $!";
> >>   }
> >
> > Or if you want to write it as a one liner,
> > you can exploit that unlink also takes a list as its arguments:
> >
> > unlink glob "c:/testdir/*030977*.*" or die "No files unlinked: $!";

That's not very good error-reporting.  Maybe unlink failed 
ninety-nine times and succeeded once...
 
> Neither of these worked.

Did they give any error messages?

> my $test = ("c:\\testdir\\testfile.txt");
> unlink glob ($test) || die "unlink failed: $!";
                      ^^

And that's the wrong "or".  If you use the alphabetical "or", 
you'll at least get an error message.

    unlink $test or die "unlink: $test: $!";

-- 
Steve

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to