http://qs1969.pair.com?node_id=11142986


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