in reply to Re: finding colunm header which crossing multiple rows
in thread finding colunm header which crossing multiple rows
Or
$_ = <DATA>; my @titles = split; my @lens = map length, /\S+\s*/g; $lens[-1] = '*'; my $pat = join "", map "A".$_, @lens; while (defined( $_ = <DATA> ) && /\S/) { my @more = unpack($pat, $_); for my $i (0..$#titles) { $titles[$i] .= ' '.$more[$i] if length($more[$i]); } }
This can be reduced to the following:
$_ = <DATA>; my @titles = split; my @lens = map length, /\S+\s*/g; $lens[-1] = '*'; my $pat = join "", map "A".$_, @lens; while (defined( $_ = <DATA> ) && /\S/) { my @more = unpack(" ".$pat, $_); $titles[$_] .= $more[$_] for 0..$#titles; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: finding colunm header which crossing multiple rows
by cscu2007 (Novice) on Nov 16, 2018 at 21:21 UTC |