Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I'd have to inspect the source code, but this looks like a handle leak to me:

    Win32::File::Object->new('file.txt', 'autowrite')->readonly(0);
    Is the object a wrapper for the underlying filehandle? Or more abstract than that? If it is a handle wrapper, is it being closed automatically? I'm not sure.

    And, since I'm a Ruby troll:

    require 'win32/file'
    File.set_attributes('file.txt', File::READONLY)
    • There's no handle leak, because there's simply no filehandle.

      It uses the GetAttributes( 'filename', $bitfield ) C function, which doesn't need to open a filehandle because it just reads from filesystem metadata or something...

      If you REALLY want API bling, I'm sure I could make

      use Win32::File::Functions;
      set( readonly => filename );

      or even just...

      readonly $filename;

      or seventeen alternative API styles.