my %MSISDN=(); #populate the subscription list to hash MSISDN open(FILE,"/tmp/subscription_list") || die "Unable to open sub +scription file"; %MSISDN = %{ file_merge(\%MSISDN) }; close(FILE); my %Calls=(); #populate the usage types to hash Calls open(FILE1,"/tmp/Call_Det")|| die "Unable to open call_details +file"; %Calls = %{ file_merge(\%Calls) }; close(FILE1); } sub file_merge { ## take from @_ (the args passed to the subrtn) my $hash_ref = shift; while (<>) { chomp; my ($key, @values) = split /-/, $_; push @{$hash_ref{$key}}, [ @values ]; } return $hash_ref; }