Here is my input file snippet "Input.xml" (Its a huge XML file of nearly 30MB with 400000 lines):
<Reasons id="ABC" name="PJ1:PJ"> <modDate>2010-03-18T09:20:05.793-03:00</modDate> </Reasons> <Reasons id="DEF" name="PJ2:PJ"> <modDate>2010-03-18T09:19:56.997-03:00</modDate> </Reasons> <Reasons id="GHI" name="ADD"> <modDate>2010-03-18T11:12:00.147-03:00</modDate> </Reasons> <Reasons id="JKL" name="ADD"> <modDate>2010-03-18T11:15:16.597-03:00</modDate> </Reasons>
I am trying to extract all the "Reasons" by reading the file into array and then joining to scalar then retaining only the wanted stuff by substitution. My Perl code is as follows:
#! /bin/env perl use warnings; if (! open R21WORKINGCONFIG, "<", "Input.xml") { die "Cant open Input.xml for input"; } @workingConfig = <R21WORKINGCONFIG>; chomp @workingConfig; $domainProperty = "Reasons"; $scalarWorkingConfig = join "XXXXX", @workingConfig; $scalarWorkingConfig =~ s/.*(XXXXX[ | ]*<$domainProperty .*$domainPr +operty>).*/$1/g; print join ("\n", split (/XXXXX/, $scalarWorkingConfig))."\n"; close R21WORKINGCONFIG;
But unfortunately, the substitute does not match the entire set of "Reasons" but only the last one. Here is the output that I get:
<Reasons id="JKL" name="ADD"> <modDate>2010-03-18T11:15:16.597-03:00</modDate> </Reasons>
The question is why is the substitute command not matching the entire set of Reasons? I think the reg-ex is pretty straight forward. Where is it that I am going wrong?
In reply to How to make substitute greedy like sed's substitute by PerlJedi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |