#!/usr/bin/perl -w use strict; use Bio::Perl; use Data::Dumper; my @var; my @gff; my @fields; my @results; my $gff; my $gfffilename; my $string; my $name; my $line; my $var; my $score; my $column; @fields=(); @results=(); @var=(); @gff=(); my %score; my $varfilename; my $ref; # sub routinen ########################### sub read_gff_file { print "Enter the filename of your input file with the single columns of your gff file:= "; chomp( my $gfffilename= ); open my $gff_fh, '<', $gfffilename or die "$gfffilename Can not open file\n"; # only read first line chomp( my $gff = <$gff_fh> ); return $gff; } sub open_var_file { print "Enter the filename of your input file with the variants:= "; chomp( my $varfilename= ); open my $var_fh, '<',$varfilename or die "$varfilename Can not open file\n"; return $var_fh; } sub do_my_job { my @column = split(/\t/,&read_gff_file()); my $var_handle = open_var_file(); while ( my $line = <$var_handle> ) { chomp $line; # should reveal 3 fields like (A,A1,A2) my @fields = split /\t/, $line; my @result = @column; splice(@result,2,0,@fields); print join( ' ', @result ), "\n"; } } # main program ########################### foreach (my $var_fh) { ($name,$score) = split; # get score $score{$_} = $score; # record it } print sort { $score{$a} <=> $score{$b}; } @var; do_my_job();