Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: Extract table from a block of text (updated)

by LanX (Saint)
on Sep 21, 2014 at 11:07 UTC ( [id://1101448]=note: print w/replies, xml ) Need Help??


in reply to Re: Extract table from a block of text
in thread Extract table from a block of text

Hi Choroba,

As a side note:

Instead of parsing the sequence number $line you could apply the technique described in Re^4: grep trouble (body of flip-flop range) to skip the boundaries of the flip and the flop. :)

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)

UPDATE

in hindsight it's a bad idea to use something like:

#!/usr/bin/perl use warnings; use strict; while (<DATA>) { if (/^INFO START$/ .. /^END$/ and not //) { print "$_"; } } __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 ...

While it does only print the inner range ...

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
... it's vulnerable to mess up the empty match // (i.e. match again the last successfully matched regular expression) by any other regex happening within the if-branch. :-/

The usual trap of global dependencies!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1101448]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-19 02:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found