ForeverLearning has asked for the wisdom of the Perl Monks concerning the following question:
I'm looking for a quick way to change the date format within an XML file from UTC (e.g. Fri, 18 Mar 2016 03:41:43 GMT) to an XPATH compliant format so that I can use XPATH date queries.
All the dates I need to change are nicely contained within <Last-Modified></Last-Modified> tags.
I have tried this... perl -pe 's/<Last-Modified>(.*)<\/Last-Modified>/`date -d \"$1\" \"+%s\"`/ge&&s/\n//' mydoc.xml
But despite the presence of the global flag, it only seems to change the first and not all instances within the doc ?
What am I missing ? ;-(
p.s. yes, I know epoch is not xpath but that was just for my test purposes
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Global matching not working as expected
by Corion (Patriarch) on Mar 19, 2016 at 09:35 UTC | |
by BillKSmith (Monsignor) on Mar 19, 2016 at 13:51 UTC | |
by ForeverLearning (Novice) on Mar 20, 2016 at 12:45 UTC | |
|
Re: Global matching not working as expected
by afoken (Chancellor) on Mar 19, 2016 at 10:56 UTC |