>>>>> "WE" == Wernher Eksteen <crypt...@gmail.com> writes:


  WE> Pseudo name=emcpowerd
  WE>   1 lpfc                      sdba     SP A7     active  alive      0     
 0
  WE>   1 lpfc                      sddd     SP B7     active  alive      0     
 0
  WE>   3 lpfc                      sdfg     SP B6     active  alive      0     
 0
  WE>   3 lpfc                      sdhj     SP A6     active  alive      0     
 0
  WE> Pseudo name=emcpowerc
  WE>   1 lpfc                      sdbb     SP A7     active  alive      0     
 0
  WE>   1 lpfc                      sdde     SP B7     active  alive      0     
 0
  WE>   3 lpfc                      sdfh     SP B6     active  alive      0     
 0
  WE>   3 lpfc                      sdhk     SP A6     active  alive      0     
 0
  WE> Pseudo name=emcpoweraz
  WE>   1 lpfc                      sdbh     SP B7     active  alive      0     
 0
  WE>   3 lpfc                      sddk     SP B6     active  alive      0     
 0
  WE>   1 lpfc                      sde      SP A7     active  alive      0     
 0
  WE>   3 lpfc                      sdfn     SP A6     active  alive      0     
 0

  >>> From the list above, how can Perl assign the sd* disks to it's
  WE> relevant emcpower device, so that the output shows this:

  WE> emcpowerd    sdba sddd sdfg sdhj
  WE> emcpowerc    sdbb sdde sdfh sdhk
  WE> emcpoweraz  sdbh sddk sde sdfn

  WE> This is how the @power array was obtained:

  WE> $powermt = 'powermt display dev=all';
  WE> @power = `$powermt`;

  WE> foreach my $i (@power) {
  WE>        if (($i =~ /emcpower*/) || ($i =~ /lpfc*/)) {

that * isn't doing what you think it does. perl regexes are not shell
globs. it happens to work anyway since the tokens are unique
enough. read perlretut to learn perl regexes.

what have you tried so far? you know enough perl to get the array of
lines and loop over that. in english (or your native tongue), just
describe how you would do it to get to your goal. write it down. it is
only a few steps. then it will be easier to convert that to the perl
needed to accomplish it. if you then have more troubles, post your code
here and you will get help. a clue: you need a hash and its values will
be array references. read perlreftut, perllol and perldsc for more on
that.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to