#!/usr/bin/perl -w # always use strict and warnings (-w from above) use strict; # 1 and 2 my %new_hash = create_hash('in_file.txt'); # 3 while(my($key,$val) = each %new_hash) { print "$key => $val\n"; } sub create_hash { my $filename = shift; my %hash; # 1.1 open(FILE,'<',$filename) or die "can't read $filename: $!"; # 1.2 - you get the point ;) while (my $line = ) { chomp $line; my($key,$val) = split (':',$line,2); $hash{$key} = $val; } return %hash; }