#!/usr/bin/perl -w use strict; use warnings; open( my $in, "c:/Documents and Settings/mydir/Desktop/current/mart_export.txt" ); open( my $out, ">c:/Documents and Settings/mydir/Desktop/current/mart_export_counts.txt" ); my $first_line = <$in>; chomp $first_line; my %clone_hash; while (<$in>) { chomp; my @fields = split /\t/; my ($gene_symbol, $esc_qc, $qc_id) = ($fields[1], $fields[8], $fields[9]); #my $count = 0; #my $clone1 = 0; $clone_hash{$gene_symbol} = $esc_qc; } # sort the oligos by gene_symbol my @sorted_keys = sort { $a <=> $b || $b cmp $a } keys %clone_hash; foreach my $key (@sorted_keys) { print $out "$key = $clone_hash{$key}\n"; } close ($in); close ($out);