Larsen, Errin M HMMA/IT wrote: > Hi everyone, > > I've got a command (if you're familiar with EMC and PowerPath, you'll > recognize the output) that outputs a long list of information like > this: > > # powermt display dev=all > Pseudo name=emcpower0a > Symmetrix ID=000187720658 > Logical device ID=00AD > state=alive; policy=SymmOpt; priority=0; queued-IOs=0 > > ======================================================================== > ====== > ---------------- Host --------------- - Stor - -- I/O Path - -- > Stats --- > ### HW Path I/O Paths Interf. Mode State > Q-IOs Errors > > ======================================================================== > ====== > 3072 [EMAIL PROTECTED]/SUNW,[EMAIL PROTECTED] > c5t50060482CC18F487d109s0 FA 8aA > active alive 0 0 > 3073 [EMAIL PROTECTED]/SUNW,[EMAIL PROTECTED] > c6t50060482CC18F497d109s0 FA 8bA > active alive 0 0 > 3074 [EMAIL PROTECTED]/SUNW,[EMAIL PROTECTED] > c7t50060482CC18F488d109s0 FA 9aA > active alive 0 0 > 3075 [EMAIL PROTECTED]/SUNW,[EMAIL PROTECTED] > c8t50060482CC18F498d109s0 FA 9bA > active alive 0 0 > > That's the output from ONE device, there are sometimes hundreds of > these. What I'd like to do is transform this into the following: > > emcpower0a -> c5t50060482CC18F487d109 > emcpower0a -> c6t50060482CC18F497d109 > emcpower0a -> c7t50060482CC18F487d109 > emcpower0a -> c8t50060482CC18F497d109 > > I wrote some code to attempt this, but I'm way off ... I know there's > a way to do this, it's just eluding me. The code I was trying out is > below. I wouldn't run it, it fails miserably: > > #!/usr/bin/perl > > use warnings; > use strict; > > my @powerout = `powermt display dev=all`; > my $name = 'NoHit'; > my @device; > > foreach( @powerout ) { I think you were close, just change the code around:
if ( @device ) { # have some items to report print "$name = $_\n" foreach( @device ); $name = undef; @device = undef; $name = 'NoHit'; # lets you know you missed the device name } # now you print if you have Sorry, but dont have access to powermt, should be close, I think. Wags ;) > $name = $1 if /Pseudo name.*(emc.*)$/; > push @device, $1 if /(c\dt.+)s\d/; > } > > } > > Thanks ahead-of-time for any help! > > --Errin ******************************************************* This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. ******************************************************* -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>