Seeing the code that was working as well as the code that doesn't work would be helpful. As is, it's kind of a guessing game. Do you want the output of "df -k" to go to the screen, or is that what you are trying to nicely format? Do you want the result of the format to go to the screen or to a file? Why do you want it in a subroutine? Is that just to make the main code cleaner or do you need to use it somewhere else as well? If the latter, what is needed in that somewhere else? Output to the screen? The formatted output returned in a variable?