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

Re^3: Split string after 14 Line Feeds? (//g)

by tye (Sage)
on Dec 04, 2012 at 05:24 UTC ( #1006999=note: print w/replies, xml ) Need Help??

in reply to Re^2: Split string after 14 Line Feeds? (//g)
in thread Split string after 14 Line Feeds?

Indeed. I conflated two similar techniques: getting a list of matches from /(...)/g and getting a list of matches from /(...)(...)(...)/. You don't get a list of matches from /(...)*/ (nor from /(...)*/g).

What I should have written was:

my @chunks = $description =~ /\G((?:[^\n]*\n){14}|.+)/gs;

(tested even; works even)

Update: Changed last * to + to eliminate extra empty string in result that I just noticed which is due to "quirk" in Perl regex processing (something I think we should just 'fix', but that is a story for another node, one I've written at least once already).

- tye        

Replies are listed 'Best First'.
Re^4: Split string after 14 Line Feeds? (//g)
by johnfl68 (Beadle) on Dec 04, 2012 at 07:41 UTC
    Thank you very much! That works great!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006999]
[ambrus]: Corion: those are good rules.
[ambrus]: Discipulus: oh sure. the input data has different filenames every time I get them.
[ambrus]: the directory structure may be 1, 2, or 3 deep, it may have spaces in the filename or not, it has dates in various format, different keywords for the same meanings, and the dates and other keywords are assembled in various ways.
[Discipulus]: no ambrus by specification i mean for example license per core instead of per socket, so fields are different

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2017-03-29 12:18 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (351 votes). Check out past polls.