I would concur strongly with the comments of cjf directing attention to the Filesys::Df module which implements disk space checking via a statvfs call (via XS code within the Filesys::Statvfs module) - An example of usage of this module can be found on this site here.
This module however is not wholly portable to Windows platforms, for which, the module Win32::AdminMisc may be more appropriate - See here for an example of this module in usage.