in reply to splicing time
Meanwhile, the script is reading the output from some other process. (Is the data sample the exact output of that process? If not, it would be better to show us that output.)
If the problem is that the first line of output from the other process (the column headings?) has more fields than any of the other lines, why even worry about it? Just skip that line:
If you actually need to keep the column headings (e.g. to use them as hash keys later), just remove the "P" column from that one line before splitting it:open( SANCLI, "datapath query essmap |" ) or die "unable to open pipe. +.. $!"; $_ = <SANCLI>; # read first line, do nothing with it while(<SANCLI>) { ...
If I'm not answering your question, please try to be more clear about what the problem is.open( SANCLI, "datapath query essmap |" ) or die "unable to open pipe. +.. $!"; $_ = <SANCLI>; s/\s+P\s+/ /; my @col_headings = split; while(<SANCLI>) { my %fields; @fields{@col_headings} = split; ... }
|
|---|