Editing columns

Hi, I have a file with a title for some rows but not all. I tried looking for examples of this but I am not sure what its called.

The file looks something like this:

name date 1 2 3
2 3 4
5 6 7
3 4 6
title author 1 3 5
2 3 5
2 3 2

Its hard to describe what I want to do with it but I want it to look like this:

name date 1 2 3
name date 2 3 4
name date 5 6 7
name date 3 4 6
title author 1 3 5
title author 2 3 5
title author 2 3 2

So basically adding the first two columns so the rows below until a different title appears...

kylle

awk '{if (NF==5) {old1=$1; old2=$2}
         if (NF==3) {printf("%s %s ", old1, old2)}
       print $0 
       } ' inputfilename > outputfilename

An other way ...

awk '{if($1&&$2 !~ /[0-9]/) {a=$1;b=$2;print} else {print a,b,$0}}' file
my $tmp;
while(<DATA>){
	if(/^([a-zA-Z ]+)/){
		$tmp=$1;
		print;
	}
	else{
		print $tmp,$_;
	}
}
__DATA__
name date 1 2 3
2 3 4
5 6 7
3 4 6
title author 1 3 5
2 3 5
2 3 2

this will also do..

awk 'NF<4{print prev" "$1" "$2" "$3}NF>4{print;prev=$1" "$2}'  filename