in reply to Unable to constrain the effect of a negative lookahead
#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11142984 use warnings; $_ = <<END; run_type = dev, max_monitor_time = 0.25 verbosity_level = 2 batch = ( source = sample_document_collection_1 files = Confucius.docx dest = Enterprise:Department ) END my @want = grep defined, /\bbatch =/ && # there is a 'batch =' /^(?:\h*batch\s+=[\s\S]*\z # skip rest of string | \h*(.*=.*?),?\h*\n) # the pattern we want /gmx; use Data::Dump 'dd'; dd \@want;
Outputs:
[ "run_type = dev", "max_monitor_time = 0.25", "verbosity_level = 2", ]
|
|---|