CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Get disk usage without modules


New User

Feb 5, 2018, 4:45 AM

Post #1 of 5 (6961 views)
Get disk usage without modules Can't Post

Hi all,
I am looking for a code in perl that can tell me the disk usage of directories, but without using any outside module. No "df", no "use Filesys::DiskUsage qw/du/;" and etc. it should work on perl v5.8.4 without any additional libraries. Any help will be highly appreciated.

Thanks in Advance


Feb 5, 2018, 9:05 AM

Post #2 of 5 (6954 views)
Re: [borodache] Get disk usage without modules [In reply to] Can't Post

You have not come to the right place to 'look for code'. We are happy to help you write your own. This is especially true of homework assignments. Its hard to imagine any other reason why you would ask for help with Perl, and then forbid the use of its greatest asset, its library of existing modules.

The first thing you must do is clarify your specification. Clearly you want the space used by the directory file and all the files that it contains. Does this include sub-directories and all the files they contain? Recursive? Do you include linked directories? files? Do you want just the size of the data in the files or do want to include space 'wasted' by the file? There probably are other issues which I forgot.

You will get more useful help if you clearly specify your constraints. What OS will it run on? About how many files do you have to process? Is there a constraint on size or speed? Do you have internet access? Do you have a standard perl v5.8.4 installation? Are any of these the reason you think you cannot use a module?
Good Luck,

Veteran / Moderator

Feb 5, 2018, 12:48 PM

Post #3 of 5 (6952 views)
Re: [borodache] Get disk usage without modules [In reply to] Can't Post

Cross-posted on Perl Monks:

There is nothing wrong with cross-posting questions, but it is considered proper to inform your reader to avoid duplication of work on various parts of the Internet.

New User

Feb 6, 2018, 8:03 AM

Post #4 of 5 (6932 views)
Re: [BillKSmith] Get disk usage without modules [In reply to] Can't Post

Thank a lot for the help. This problem was not for school, but let's forget from this issue. I intended of course to the recursive option, including size of subdirectories and sub-subdirectories. However, I got my answer in perl-monks forum.

Thanks, anyway.


Feb 7, 2018, 9:12 AM

Post #5 of 5 (6916 views)
Re: [borodache] Get disk usage without modules [In reply to] Can't Post

I understand that you think you have a solution without the trouble of answering my questions. Your responders had to assume answers. Consider the possible consequences of wrong assumptions. Probably the worst is answers which are 'wrong' because they do not mean exactly what you intend and you do not know it! The solution may 'work' initially, but fail in the future when you first encounter something unusual (such as a link). If your OS is windows, your 'solution' will probably crash.

Please note that I am not finding fault with perlmonks. They did not have the information needed to give you a solid solution.
Good Luck,


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives