Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

return to previous option

by Vanhalen (Initiate)
on Oct 19, 2011 at 18:07 UTC ( #932457=perlquestion: print w/replies, xml ) Need Help??
Vanhalen has asked for the wisdom of the Perl Monks concerning the following question:

Hi getleman Im perl beginner who just started learning. I just want to figure out of a way to do something in perl that will be very useful for my line of work. For now what I want is this. 1. Want to findout the partition with most free space. (df -h) for an instance say I have /dev/sda1 with 20% free space and /dev/sda2 with 30% 2. I want to print this to the user as follows select the partition with the most space: 1. /dev/sda2 2. /dev/sda1 3. if user hit any key other than 1 or 2 the script has to say wrong choice and go back to the 2nd point( select partition with most space?) without exiting. What is the easiest way of doing this people? Please help out sir.

Replies are listed 'Best First'.
Re: return to previous option
by GrandFather (Sage) on Oct 19, 2011 at 19:49 UTC

    Show us what you have tried. Read the Lama (Learning Perl). Read through our Tutorials section. There are many parts to the script you describe, although the solution is likely to be only a few tens of lines long. You will learn a lot by doing the reading and solving the problems for yourself. An ideal little project for a Perl beginner.

    True laziness is hard work

      I agree, even more interesting if you avoid the use of the function system, the most obvious solution for a beginner, and use the perl modules for this.

Re: return to previous option
by Anonymous Monk on Oct 19, 2011 at 23:05 UTC


    Just pointing out that using percentages assumes that each partition will be the same size.

    On most of the systems I have worked on this would not be true.


      good point, You can show the number of free blocks in each partition instead

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://932457]
Approved by GrandFather
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2017-05-25 18:28 GMT
Find Nodes?
    Voting Booth?