|P is for Practical|
Counting devices types, device sizes and number of devices.by perl514 (Pilgrim)
|on Jan 03, 2012 at 06:36 UTC||Need Help??|
perl514 has asked for the
wisdom of the Perl Monks concerning the following question:
I want to count the size and type of devices in my Storage Array. Here is how the output looks:
I need the output so that it tells me something like:
The output shown above is obtained by running command:symdev -sid 1234 list -noport -noreserve|find /I "not visible"
So am trying to figure out how to pass the output of this command to a Filehandle so that I can try out stuff given in the node 504596. Is that a good way to go about it?
Now, thing is, in this output, there are 3 things that will vary.
1) The Type of RAID (2 Way Mir, or RAID5, Or BCV+R5, or something else).
2) The Size of Devices: This too will vary and could be different from the sizes given above.
3) the count of such type of devices.
I tried using split function, but I can get it to split on a line or a white space. Once I hold the split items in an array, I cant further split it, because the split function works in a scalar context.
Then I thought of using a hash, but from what I know, a hash can only have one value associated with a key. Is there a way to have multiple values associated with a hash key? I was planning to use 504596 as a reference to do it. Would that be the right way to go about this? Would redirecting the command output to a text file using a filehandle and then reading from it give me any advantages? I browsed through some articles, but nothing seems to make things clear for me.
I am not asking for a ready made code for this, as that will refute the very purpose of me trying to learn Perl. But I would kindly request me to guide to some pointers that will help me do it. Please help.
Perlpetually Indebted To PerlMonks