Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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

by LanX (Bishop)
on Sep 21, 2014 at 11:07 UTC ( #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
Node Status?
node history
Node Type: note [id://1101448]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2018-09-21 08:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Eventually, "covfefe" will come to mean:













    Results (185 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!