[Kc] strawberry error messages are inferior to windows native error messages

David Nicol davidnicol at gmail.com
Wed May 11 11:44:59 PDT 2011


An idiom I have found useful, to process all files in the current directory,
with a certain extension, is:

    for (glob("*.something")){

        open F, '<', $_ or die "open: $!";
        dosomethingwith(join '',<F>);
        rename $_, "$_.processed" or die "rename: $!"
    };

This has served, and continues to serve, very well, in various situations.

I tried that today on a Windows machine and got "rename: permission denied."
I further loosened the security on the working directory to no effect.

Eventually I tried

     die `move $_ $_.processed`;

instead of the rename line and got a different error message, about the file
being opened by another process.

Then I remembered: Perl does not automatically close a file handle when it
is done reading it. You can seek() on the handle and to reread the file from
the beginning, or maybe the file will grow at the end -- anyway, the handle
is open, and Windows won't let you rename a file that has open handles on
it.

A "close F" before the rename took care of the problem.

Is this worth trying to file as a bug with the Strawberry Perl project, that
the error messages can be misleading?

In general, your takeaway from this note is to supposed to be a a reminder
that Perl (at least Strawberry -- haven't tried my idiom with ActiveState)
error messages on Windows are inferior to the error messages from native
tools, and may be incorrect.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/kc/attachments/20110511/36833566/attachment.html>


More information about the kc mailing list