[Omaha.pm] Count occurrences of the value of an attribute in XML

Jay Hannah jay at jays.net
Tue May 29 21:56:36 PDT 2007


On May 29, 2007, at 9:03 PM, Andy Lester wrote:
> On May 29, 2007, at 7:39 PM, Jay Hannah wrote:
>> $ perl -lne '/rt="(\w+)"/; print $1' RevData.DALMAN.20070529.xml |  
>> uniq
>
> I would put a \b in front of the rt so you don't match cart="foo".

Ya. I like that. Thanks!

On May 29, 2007, at 9:04 PM, Andy Lester wrote:
> Actually, this is wrong.  You cannot rely on the value of $1 if the
> m// did not match.  Your "optimization" to /rt.../ && print $1 is
> necessary or else it is wrong.

Yup. That's why I posted that correction 2 minutes after my first  
post. Thanks,

j




More information about the Omaha-pm mailing list