in reply to Re: Re: Re: Re: Formatted Text
in thread Formatted Text

You are trying to use the same filehandle DISKSPACE for reading the output of df and for writing your formatted result. Get rid of the system "df -k \n"; in the main code, change your first open in df_total to:
open DISKSPACEIN, "df -k|" or die "couldn't start df -k: $!";
(The | means to execute the given command and make it's output available via the filehandle. See perlipc.)

Then change your while (<DISKSPACE>) to while (<DISKSPACEIN>).

It's also an especially good idea when using pipes (the "df -k|" argument to open makes what's called a pipe) to explicitly close the filehandle and check the result, so after the while loop, put:

close DISKSPACEIN or die "got df error: $! $?";
See perlipc for more about this.