Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Joining multiple lines together while parsing

by tybalt89 (Monsignor)
on Mar 24, 2017 at 22:44 UTC ( [id://1185843]=note: print w/replies, xml ) Need Help??


in reply to Joining multiple lines together while parsing

#!/usr/bin/perl -l # http://perlmonks.org/?node_id=1185742 use strict; use warnings; $/ = 'Dumpdata example ----------------- '; while(<DATA>) { chomp; my @answer = map s/\s+/ /gr =~ s/\s+\z//r =~ s/.*/"$&"/sr, /^Warning (.*)/gm, /^\s*\w+:\s*(\S.*(?:\n(?!\s*\w+:)\s*\S.*)*)/gm; @answer and print join '; ', @answer; } __DATA__ Dumpdata example ----------------- Warning bad news here Detail: Some really nice infos these are Info: This is a problem but there is a solution Spec: 2nd of 4 Dumpdata example ----------------- Warning test Detail: foo bar Info: quz baz Spec: blah

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-23 21:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found