Code:
#!/bin/perl
use strict;
# Accept the input and output files as parameters
my $input_file = $ARGV[0];
my $output_file = $ARGV[1];
# Set the header columns to be added to the left
# and to the right of the header in the input file
my @left = (
"Index",
"Chromosome Position",
"Gene",
"Inheritance",
"RNA Accession",
"Chr",
"Coverage",
"Score",
"A(#F,#R)",
"C(#F,#R)",
"G(#F,#R)",
"T(#F,#R)",
"Ins(#F,#R)",
"Del(#F,#R)",
"SNP db_xref",
"Mutation Call",
"Mutant Allele Frequency",
"Amino Acid Change"
);
my @right = (
"HP",
"SPLICE",
"Pseudogene",
"Classification",
"HGMD",
"Disease",
"Sanger",
"References"
);
# open the input file, read the header line and sandwich it
# between @left and @right arrays
my $final_header;
open (FH, "<", $input_file) or die "Can't open $input_file: $!";
chomp(my $hdr=<FH>);
$final_header = sprintf("%s\t%s\t%s\n", join("\t", @left), $hdr, join("\t",@right));
# final header is set, print it to the output file
open (OF, ">", $output_file) or die "Can't open $output_file: $!";
print OF "$final_header";
# close (FH) or die "Can't close $output_file: $!";
my @colsleft = map "Null",(0..$#left);
my @colsright = map "Null",(0..$#right);
while(<FH>) { # puts row of input file into $_
chomp;
print OF join("\t",$.,@colsleft,$_,@colsright),"\n"; # row data is set, print it to the output file
}