Baratski has asked for the wisdom of the Perl Monks concerning the following question:

Hello.

I'm just curious. Should I use Win32API modules for file operations on my Windows computer, or does it really matter?

When experimenting, (learning), I do this:

open F, ">$file"; print F $stuff; close F;

I also use, read(), seek(), tell()....

But Win32API::????? File.pm, (85KB), is full of all sorts of interesting items. Should I use it? What's it for?

This probably will register as a stupid question, since I never end up with corrupt files. I wrote a little file splitting program for myself, and everything works out fine.

Thank you.

Replies are listed 'Best First'.
Re: Win32API modules
by keszler (Priest) on Jul 03, 2004 at 22:02 UTC
    A better question is do you need to? If you need the low-level access, sure - it's a standard, well-tested module. But if you're just opening, reading, writing, seeking, etc. there's no good reason to go low-level.

    getLogicalDrives() can be a handy function, especially in conjunction with GetDriveType($Root). On the other hand, using IOCTL_DISK_SET_DRIVE_LAYOUT, IOCTL_DISK_FORMAT_TRACKS, and others can trash the hard drive with a simple typo. They're potentially useful, but I wouldn't play with them on anything other than a test box.

Re: Win32API modules
by aquarium (Curate) on Jul 04, 2004 at 00:11 UTC
    a good reason to use win32api is for process/services handling, as it's totally different to unix....so the only way to get at processes/services is to use win32api. btw, you don't need to import a whole module if you just want to use a single function.....use some_module::one_function only imports that function and whatever it requires.
      Thank you for both of the replys I received.
      I greatly appreciate your input. :-D