in reply to couple of file content manipulation questions
I would first look at your file and look for any patterns. Here's a good start: each server apparently ends with a line starting "AVAILABLE" followed by a blank line then two break lines. You could use these breaklines to split the servers apart from each other. Then you could take the data from each server separately, and skip any breakline or any heading line (the "next if(//)" combo is good in loops for this purpose). Otherwise, each line looks to be a tab separated list. So you can use that to split each line and store the data how you see fit.
As for the TOTAL, USED and AVAILABLE lines, that's something that I would set your loop up to search for. If it sees TOTAL on a line, grab the data associated with it, store it. Same goes for the Used line and the AVAILABLE line.
One caveat. NEVER assume the same number of tabs in a tab separated list (or space separated, etc). Make sure you use the one-or-more flag in your regexp. Otherwise, that first line, which might have two tabs in there, might not parse correctly.
Another Caveat: In some instances, it might be worthwhile to parse the heading lines and grab the headings as your hash keys. First of all, it keeps your data associated with the proper heading. Second of all, I see that on the sis8 server, the heading is different. This would cause problems if you didn't see this up front. You would likely need to nest some of your hashes in order to store the data in a logical way considering there are multiple lines of filesystems for each server.
Hope that helps you think about the world of regexp and data file parsing. It's really a whole different frame of mind.
--Coplan
|
|---|