Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Unable to constrain the effect of a negative lookahead

by johngg (Canon)
on Apr 14, 2022 at 15:50 UTC ( [id://11142986]=note: print w/replies, xml ) Need Help??


in reply to Unable to constrain the effect of a negative lookahead

Instead of a complex and possibly difficult to maintain regex I would approach the problem a different way. I would treat $SYSPBUFF as a file and read it line by line until I reached the "batch =" line, at which point I'd last out of the loop to cease reading any further. Lines of interest would be pushed onto an array ready for further processing. I haven't tried tidying the lines up, leading spaces, trailing comma etc., I'll leave that to the reader.

johngg@abouriou:~/perl/Monks$ perl -Mstrict -Mwarnings -E 'say q{}; my $SYSPBUFF = <<__EOD__; run_type = dev, max_monitor_time = 0.25 verbosity_level = 2 batch = ( source = sample_document_collection_1 files = Confucius.docx dest = Enterprise:Department ) __EOD__ open my $inFH, q{<}, \ $SYSPBUFF or die qq{open: < in mem data: $!\n}; my @lines; while ( <$inFH> ) { last if m{batch\s*\=}; next if m{^\s*$}; chomp; push @lines, $_; } close $inFH or die qq{close: < in mem data: $!\n}; say for @lines;' run_type = dev, max_monitor_time = 0.25 verbosity_level = 2

I hope this is helpful.

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 14:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found