#Assuming that you pass the file name as a parameter when executing the script. my %table; open (F1, "<$ARGV[0]") || die ("Can't open the file $ARGV[0]. $!\n"); while() { chomp; if($_ =~ /([^:]+): ([^\n]+)/) { $table{$1} = $2; } } close F1; #printing the table. for (keys %table) { print "$_\t$table{$_}\n"; }