[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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




On May 29, 2007, at 7:39 PM, Jay Hannah wrote:

$ perl -lne '/rt="(\w+)"/; print $1' RevData.DALMAN.20070529.xml | uniq

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.

See http://perl101.org/regexes.html "Don't use capture variables without checking that the match succeeded."

xoxo,
Andy

--
Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance