[olug] [Omaha.pm] Cheesy XML wrangling

trey trey-b at cox.net
Sun Mar 2 18:37:02 UTC 2008


I love ready mixed instant reports by throwning anything into sort | 
uniq -c.


----- Original Message ----- 
From: "Jay Hannah" <jay at jays.net>
To: "Nebraska USA Perl Mongers of Omaha" <omaha-pm at pm.org>
Cc: "Omaha Linux User Group" <olug at olug.org>
Sent: Saturday, March 01, 2008 10:16 AM
Subject: [Omaha.pm] Cheesy XML wrangling


> I've been doing a lot of cheesy XML parsing w/ command-line perl
> lately. Perl is great at elegant XML handling too (I'm a fan of
> XML::Twig), but it's hard to beat 30-second command line solutions to
> answer simple questions...
>
> Linux + GNU + Perl is awesome.   :)
>
> j
> preaching to the choir
>
>
> $ head -3 RevData.DALMAN.20080301.xml
> <revolutiondata asof="20080301091702" hotel="DALMAN" seq="20080301"
> ver="1.5">
>   <reservations>
>     <res actrrev="972" bktime="20070915050836" cas="N"
> doa="20071027" evt="notevent" exprrev="972" gcnt="1"
> grp="13700106165" gtd="Y" id="2009477241" inlos="6"
> intime="20071027100400" los="6" off="notoffer"
> outtime="20071102041200" rcnt="1" rt="DELUXE" seg="06" src="WB"
> st="R" time="20080301091703" xltime=""/>
>
> $ grep '<res ' RevData.DALMAN.20080301.xml | perl -nle '/rt="(.*?)"/;
> print $1' | sort | uniq -c
>   50699 DELUXE
>   16144 SUITES
>    1180 UMAN
>
> _______________________________________________
> Omaha-pm mailing list
> Omaha-pm at pm.org
> http://mail.pm.org/mailman/listinfo/omaha-pm 




More information about the OLUG mailing list