extracting fields from a matching line



Given a code segment:

my $cmd = "/usr/symcli/bin/something";
open (SYMCFG, " $cmd |" ) or die "cannot open $!\n";

while ( <SYMCFG> ) {
#print $_ if /FibreChannel Online$/ ;
# extract fields from the matching line
my ( $ident, $fa , $type, $status ) = (split )[0,1,4,5] if /
FibreChannel Online$/ ;

print "$ident $fa $type $status \n" if defined $status ;

}
close SYMCFG ;

the sample output of running $cmd 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

the question:
I would expect to print out the field 0, 1, 4, 5
from the above line, however, while the first 3 fields print OK, the
last field $status seem always got uninitialied and

Use of uninitialized value at ./emc_device_matching_to_fa.pl line 32,
<SYMCFG> chunk 23.

what I'm doing wrong?

Thanks.

.



Relevant Pages