[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Omaha.pm] Another XML hack
Problem:
Given a directory full of xml files containing lines like this:
<rmtype grpblk="29" grprrev="2755" invdate="20081226" ooo="0" physcap="319" rt="DELUXE"/>
Find any lines in RevData.DALMAN*xml where grpblk > physcap. Make sure to
identify which file the data came from.
Solution:
$ cat j.pl
while (<>) {
($grpblk) = (/grpblk="(\d+)"/);
($physcap) = (/physcap="(\d+)"/);
print if ($grpblk > $physcap);
}
$ grep '<rmtype ' RevData.DALMAN*xml | perl j.pl
RevData.DALMAN.20080417.xml: <rmtype grpblk="339" grprrev="42771" invdate="20080823" ooo="0" physcap="319" rt="DELUXE"/>
RevData.DALMAN.20080418.xml: <rmtype grpblk="339" grprrev="42771" invdate="20080823" ooo="0" physcap="319" rt="DELUXE"/>
RevData.DALMAN.20080418.xml: <rmtype grpblk="349" grprrev="43821" invdate="20080824" ooo="0" physcap="319" rt="DELUXE"/>
...
:)
j