Modifications to a file

Hi,

I do not have a clue how to do this nor can I find information on it but I have a file that looks like this (basically 3 columns and tab delimited). I need this in a particular format in order for a program to actually read it.

chr1  2  4
chr1  2  5
chr1  3  6
chr2  1  4
chr2  2  5

what I want to do is this

track type=wiggle_0 name="Name" description="Name" visibility=full autoScale=off viewLimits=-5:1.25 color=0,100,0 altColor=0,100,0 priority=30 yLineOnOff=on 
variableStep chrom=chr1 span=1
2  4
2  5
3  6

track type=wiggle_0 name="Name" description="Name" visibility=full autoScale=off viewLimits=-5:1.25 color=0,100,0 altColor=0,100,0 priority=30 yLineOnOff=on 
variableStep chrom=chr2 span=1
1  4
2  5

so basically when an identifier changes along chr1 then a header (above) is added containing the track type etc... (the header is space separeted) and then at chrom = , a name from column 1 is added (chr1 etc....). Am I clear here?

thanks

This might do it?

 awk 'p!=$1{p=$1;printf "track type=wiggle_0 name=\"Name\" description=\"Name\" visibility=full autoScale=off viewLimits=-5:1.25 color=0,100,0 altColor=0,100,0 priority=30 yLineOnOff=on\nvariableStep chrom="$1" span=1\n"}{print $2"\t"$3}' infile
my $name;
my $header='track type=wiggle_0 name="Name" description="Name" visibility=full autoScale=off viewLimits=-5:1.25 color=0,100,0 altColor=0,100,0 priority=30 yLineOnOff=on variableStep chrom=<NAME> span=1';
while(<DATA>){
	chomp;
	my @tmp=split;
	if($name eq "" || $name ne $tmp[0]){
		$name=$tmp[0];
		(my $tmp_header=$header)=~s/<NAME>/$name/;
		print $tmp_header,"\n"; 
	}
	print "@tmp[1..$#tmp]\n";
}
__DATA__
chr1  2  4
chr1  2  5
chr1  3  6
chr2  1  4
chr2  2  5