|Do you know where your variables are?|
Regex to extract certain lines only from command output/text file.by perl514 (Pilgrim)
|on Mar 07, 2013 at 17:58 UTC||Need Help??|
perl514 has asked for the
wisdom of the Perl Monks concerning the following question:
Given below is an extract from a file that I wish to extract certain portions from.
This is the 3par showhost command output. It basically shows the Host ID, the name of the host, the host setting, the HBA WWN and the 3par Storage Array port.
I just need to extract the portion, if there is a "---" or a blank line in there...such as
So basically the way I want is, the output should leave out if all the entries have a d:d:d at the end like so
So I tried a lot of stuff, and none of it worked. So I thought "Why not take everything that starts with a digit upto the part that just ends before the next digit and see if a "---" or a blank space is there.
Here is my script. I tried a lot of stuff, tried setting the $/ to "" and then to undef and then to \n\n, but it doesn't seem to work. So I removed the $/ from my script and started over (once again). As of now, my brain is completely a tangled mess, so please do not get pissed with the script below.
The script above does not output anything. I can easlity pull out just the line with the "---". Thats not a problem. What I want is, the whole host block associated with it. Any pointers would help. I am not looking for pre written code, I really badly need to crack this on my own, but I have miserably misunderstood the regex...please help me untangle my brain :).
Perlpetually Indebted To PerlMonks
http://dwimperl.com/windows.html is a boon for Windows.