#!/usr/bin/perl -w

use strict;
use warnings;

# @ARGV 

### perl script.pl *blast


my $seq="";
my @coords; 
my $query;

open(OUTPUT, '>', "./coordenades.tbl");

foreach (@ARGV) {

	my $file = $_;
	open(FILE, '<', $file);
	while(<FILE>){
		my @line = split(/\s+/, $_);
		if ($seq eq "") {
			$seq = $line[1]; 
			push(@coords, @line[8, 9]);
			$query = $line[0];
		};
		if ($seq eq $line[1]) {
			push(@coords, @line[8, 9]);
		};
	

	}; # while

	my @sortcoords = sort { $a <=> $b } @coords;
	print OUTPUT $query." ".$seq." ".$sortcoords[0]." ".$sortcoords[$#sortcoords]."\n" ;
	$seq="";
	@coords=();
	close(FILE);
	
}; #for

close(OUTPUT);

exit(0); 
