in reply to finding colunm header which crossing multiple rows
#!/usr/bin/perl # https://perlmonks.org/?node_id=1225917 use strict; use warnings; $_ = <DATA>; my @titles = /\w+/g; my @positions; push @positions, $-[0] while /\w+/g; while( <DATA> ) { /\S/ or last; for my $i (0 .. $#positions) { /^.{$positions[$i]}(\w+)/ and $titles[$i] .= " $1"; } } use Data::Dump 'dd'; dd \@titles; __DATA__ Name Company Work Home + Work Name Address Phone + Hours Number
Outputs:
[ "Name", "Company Name", "Work Address", "Home Phone Number", "Work Hours", ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: finding colunm header which crossing multiple rows
by ikegami (Patriarch) on Nov 16, 2018 at 21:12 UTC | |
by cscu2007 (Novice) on Nov 16, 2018 at 21:21 UTC | |
|
Re^2: finding colunm header which crossing multiple rows
by cscu2007 (Novice) on Nov 16, 2018 at 21:18 UTC |