thans for the reply.

I modify the program a bit , the $cmd output looks like:
========
           Ident  Symbolic  Numeric  Slot  Type          Status

    DF-1A     01A       1       1   DISK          Online
    FA-4A     04A       4       4   FibreChannel  Online
    FA-13A    13A      13      13   FibreChannel  Online
    DF-16A    16A      16      16   DISK          Online


the code is below:
==============
my $cmd = "/usr/symcli/bin/symcfg -sid 0133 list -dir all";
open  (SYMCFG, " $cmd |" ) or die "cannot open $!\n";

while (  <SYMCFG> ) {
 print $_  if /FibreChannel\s+Online/ ;
 my ( $ident, $fa , $type, $status ) = (split /\s+/ )[0,1,4,5] if /
FibreChannel\s+Online\s+$/ ;
 print "$ident  $fa  $type $status \n" if defined $status ;

}
close SYMCFG ;

then when run it:
bash-2.03# ./emc_device_matching_to_fa2.pl
    FA-4A     04A       4       4   FibreChannel  Online
  FA-4A  4 FibreChannel
    FA-13A    13A      13      13   FibreChannel  Online
  FA-13A  13 FibreChannel


if I chane the line:
my ( $ident, $fa , $type, $status ) = (split  )[0,1,4,5] if /
FibreChannel\s+Online\s+$/ ;
then I got the correct results.

    FA-4A     04A       4       4   FibreChannel  Online
FA-4A  04A  FibreChannel Online
    FA-13A    13A      13      13   FibreChannel  Online
FA-13A  13A  FibreChannel Online
    FA-4B     04B      20       4   FibreChannel  Online
FA-4B  04B  FibreChannel Online

so why the differience  with split vs split /\s+/ ?  thanks.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to