in reply to Extract table from a block of text
#!/usr/bin/perl use warnings; use strict; while (<DATA>) { if (my $line = /^INFO START$/ .. /^END$/) { next if /^$/ # Skip empty lines. or $line =~ /E/ # Skip the END line. or 1 == $line # Skip the START line. or /^STIME/; # Skip the header. my ($stime, $etime, @cols) = split; print "$stime:$etime\t$_\n" for @cols; print "\n"; } } __DATA__ ... ignore ... INFO START STIME ETIME COLUMN3 COLUMN4 COLUMN5 aaaa1 bbb1 ccc1 ddd1 eee1 aaaa2 bbb2 ccc2 ddd2 eee2 aaaa3 bbb3 ccc3 ddd3 eee3 aaaa4 bbb4 ccc4 ddd4 eee4 END ... ignore again ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Extract table from a block of text (updated)
by LanX (Saint) on Sep 21, 2014 at 11:07 UTC | |
|
Re^2: Extract table from a block of text
by Laurent_R (Canon) on Sep 21, 2014 at 10:48 UTC | |
by LanX (Saint) on Sep 21, 2014 at 10:57 UTC | |
by Laurent_R (Canon) on Sep 21, 2014 at 12:23 UTC |