jet speed wrote:
I have a file with similar data, around 10,000 entries with similar format. i need to extract the output in below format. I can match the WWN and push into an arrray, however i am not sure how to reference the WWN to its corresponding device displayDevNum as in the below format. Any help would be much appreciated. I am using test data here due to system restrictions. required output ------------------------ 10:79 10.00.00.00.00.C0.43.33.AB 10:79 10.00.00.00.00.C0.43.33.A2 10:99 10.00.00.00.00.C0.22.33.56 10:99 10.00.00.00.00.C0.34.33.A0 10:99 10.00.00.00.00.C0.22:49:33 10.55 10.00.00.00.00.C9.43.42.B6 10.55 10.00.00.00.00.C0.43.23.C9 DATA - file.txt -------------------- devNum=4,177 displayDevNum=10:79 LUN=121 WWN=10.00.00.00.00.C0.43.33.AB nickname=a5 WWN=10.00.00.00.00.C0.43.33.A2 nickname=wacke22 devNum=4,177 displayDevNum=10:99 LUN=121 WWN=10.00.00.00.00.C0.22.33.56 nickname=a2 WWN=10.00.00.00.00.C0.34.33.A0 nickname=ajx WWN=10.00.00.00.00.C0.22:49:33 nickname=yah1 devNum=4,177 displayDevNum=10:55 LUN=121 WWN=10.00.00.00.00.C9.43.42.B6 nickname=a52 WWN=10.00.00.00.00.C0.43.23.C9 nickname=wack1
$ echo 'devNum=4,177 displayDevNum=10:79 LUN=121 WWN=10.00.00.00.00.C0.43.33.AB nickname=a5 WWN=10.00.00.00.00.C0.43.33.A2 nickname=wacke22 devNum=4,177 displayDevNum=10:99 LUN=121 WWN=10.00.00.00.00.C0.22.33.56 nickname=a2 WWN=10.00.00.00.00.C0.34.33.A0 nickname=ajx WWN=10.00.00.00.00.C0.22:49:33 nickname=yah1 devNum=4,177 displayDevNum=10:55 LUN=121 WWN=10.00.00.00.00.C9.43.42.B6 nickname=a52 WWN=10.00.00.00.00.C0.43.23.C9 nickname=wack1' | perl -e' my $displayDevNum; while ( <> ) { $displayDevNum = $1 if /^displayDevNum=(\d\d:\d\d)/; print "$displayDevNum $1\n" if /^WWN=([0-9a-f.:;]+)/i; } ' 10:79 10.00.00.00.00.C0.43.33.AB 10:79 10.00.00.00.00.C0.43.33.A2 10:99 10.00.00.00.00.C0.22.33.56 10:99 10.00.00.00.00.C0.34.33.A0 10:99 10.00.00.00.00.C0.22:49:33 10:55 10.00.00.00.00.C9.43.42.B6 10:55 10.00.00.00.00.C0.43.23.C9 John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/