I'm new to Perl and need to know how to get Perl to find out how much disk space is left on any given hard disk. I have tried a few things like the following:

print `dir >dir.txt`; open (DIR, "dir.txt");

This crashed my machine - I'm using Windows 98 SE...The purpose of the above code was to get the second last line returned when dir is invoked in DOS, ie the line that contains the amount of free disk space. Once I have that, I can join/split it into an array and use the number to perform checks, etc. I've also tried the stat command:

@stats = stat "C:/";

But when I print this information to the screen, it gives me the same numbers every time (even after deleting/adding files to C:/) ...in UNIX, you can do a stat -f filename to report stats on the file system that filename resides on - I tried adding the -f to the above code, stat -f "a file on C:/"; but it returns nothing. I've also tried piping a command to DOS which crashes the computer big time - lots of blue screens, then it just kacks out.

I should also mention that I'm using the latest (build 626) version of ActivePerl...

Does anyone have any idea why these commands are crashing my computer? Any ideas on how I can get Perl to find out how much disk space is left on any drive?

I started wrting a script that checks the C: drive on a Win 98 machine for free space - when the free space gets small enough, the script looks for large files, copies them to the D: drive, compares the size of the files copied and then deletes the files on C: ...so I've completed the entire script except for the free space check. Any ideas?