Re: extracting fields from a matching line
- From: krahnj@xxxxxxxxx (John W . Krahn)
- Date: Thu, 29 Nov 2007 04:22:28 -0800
On Wednesday 28 November 2007 16:07, ciwei2103 wrote:
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.
It says "chunk 23" instead of "line 23" which means that you changed
the Input Record Separator ($/) from its default value of "\n". So
what did you change it to?
As to your missing field, that is kind of hard to diagnose without
being able to run the command myself.
John
--
use Perl;
program
fulfillment
.
- References:
- extracting fields from a matching line
- From: Ciwei2103
- extracting fields from a matching line
- Prev by Date: Cannot understand this fragment of code
- Next by Date: Can't understand this.
- Previous by thread: extracting fields from a matching line
- Next by thread: Perl upgrade @INC help
- Index(es):
Relevant Pages
|