Quoting nate at refried.org (nate at refried.org):
> Bah!  Perl sucks.  All hail the power of pipes. 
> 
> for package in `rpm -qp --queryformat="%{NAME}\n" *.rpm | sort | uniq -d`; do
>   packages=$(rpm -qp --queryformat="%{NAME},%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm\n" ${package}* | grep ${package}, | cut -d, -f2)
>   while [ `echo $packages | wc -w` -gt 1 ]; do
>   	deletenext=$(echo $packages | cut -d' ' -f1)
> 	echo "I think I'll delete $deletenext"
> 	packages=$(echo packages | cut -d' ' -f2-)
>   done
> done
> 
> Add in the rm line when you're ready for it.

I hacked the previous perl program to do what I needed. Your solution using
--queryformat is slick though.

-- 
Minneapolis St. Paul Twin Cities MN        | Phone : (952)943-8700
http://www.mn-linux.org Minnesota Linux    | Fax   : (952)943-8500
Key fingerprint =  6C E9 51 4F D5 3E 4C 66 62 A9 10 E5 35 85 39 D9