extracting fields from a matching line
- From: ciwei2103@xxxxxxxxx (Ciwei2103)
- Date: Wed, 28 Nov 2007 16:07:27 -0800 (PST)
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.
.
- Follow-Ups:
- Re: extracting fields from a matching line
- From: John W . Krahn
- Re: extracting fields from a matching line
- Prev by Date: re: extracting fields from a matching line
- Next by Date: Re: Variable division, assignment and sprintf in one line
- Previous by thread: re: extracting fields from a matching line
- Next by thread: Re: extracting fields from a matching line
- Index(es):
Relevant Pages
|
|