#!/usr/bin/perl #use strict; #use warnings; my %hash; open (my $fh,"<", "c:/asso2.txt") or die "Can't open the file: "; while (my $line =<$fh>){ chomp ($line); if ($line =~ /\d\s+\w/){ my ($index, $data)=split (/\s+/,$line); #split on the basis of space $hash{$index} =$data; #Assign the value to key } } foreach my $i(sort keys %hash){ print "$i =$hash{$index}\n"; }