Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find disk space using perl in Windows machine?

Tags:

perl

I need to get the free disk space, total disk space in windows machine using perl.

For an example,

use strict;
my $curr_drive="c:\";

From the above code, I want to get the c:\ drive free space and total space. I have tried with Filesys::DiskSpace module. But I dont how to proceed the module for windows. Please share your solutions.

Thanks

like image 944
Madhan Avatar asked Feb 16 '12 14:02

Madhan


1 Answers

The module Filesys::DiskSpace is unsupported on Windows. You have to use Win32::DriveInfo.

Try the following:

use strict;
use warnings;

use Win32::DriveInfo;

my (undef, undef, undef, undef, undef, $total, $free) =
    Win32::DriveInfo::DriveSpace('c');
like image 130
Stamm Avatar answered Nov 15 '22 04:11

Stamm