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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|