The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/bin/bash
# ./store_rpt mv -v 1.34
function do_cp {
    for r in $r
      do 
      for f in $(grep -l "$grep$r" $m)
      do 
        mkdir -p t/reports/$v/$r
	if test "$move" = "1"
	then
	    mv $f t/reports/$v/$r/
	else
	    cp -p $f t/reports/$v/$r/
	fi
      done
    done
}

if test "$1" = "mv"; then move=1; shift; fi
if test "$1" = "-v"; then
  v=$2
else
  v=`perl -ane'print $F[2] if /^VERSION =/' Makefile`
fi

m=$(ls log.modules-5.*|egrep -v ".(orig|err)")
if [ -n "$m" ]; then
    r=$(perl -lane "print substr(\$F[4],1) if /VERSION = $v r/" $m)
    if [ -n "$r" ]; then
	grep="VERSION = $v r"
    else
	r=$(perl -lane "print \$F[4] if /^# B::C::VERSION = 1.\\d\\w+ \\w+ /" $m)
	grep="VERSION = $v "
    fi
    do_cp
fi

m=$(ls log.test-*-5.*|egrep -v ".(orig|err)")
if [ -n "$m" ]; then
    r=$(perl -lane "print \$F[1] if /^Revision: \\d+\$/" $m)
    if [ -n "$r" ]; then
        # svn
	grep="Revision: "
    else
	# git
	r=$(perl -lane "print \$F[4] if /^# B::C::VERSION = 1.\\d\\w+ \\w+ /" $m)
	grep=" "
    fi
    do_cp
fi