Skip to content

Instantly share code, notes, and snippets.

@Buttonwood
Created March 13, 2015 07:32
Show Gist options
  • Select an option

  • Save Buttonwood/0f7ebcb4167f01fa468e to your computer and use it in GitHub Desktop.

Select an option

Save Buttonwood/0f7ebcb4167f01fa468e to your computer and use it in GitHub Desktop.
use Data::Dumper;
while (<>) {
my @tmp = split(/\s+/,$_);
my $head = join("\t",@tmp[0,1,2,3]);
my $end = &store_hash($tmp[9],$tmp[10]);
my @key = sort {$a <=> $b} keys (%$end);
foreach my $x (@key) {
my $last = $end->{$x};
print "$head\t$x\t$last\n";
}
}
sub store_hash{
my $a = shift;
my $b = shift;
my @aa = split(/\,/,$a);
my @bb = split(/\,/,$b);
my %h;
#print Dumper(\@aa);
#print Dumper(\@bb);
for (my $var = 0; $var < $#aa; $var++) {
$h{$aa[$var]} = $bb[$var];
}
#print Dumper(\%h);
return \%h;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment