#!/usr/bin/perl -w use strict; my $line = ; my %hash = (); while ($line) { # and $line ne ""){ chomp($line); if($line =~ /^(\S+)\s+(\d+)$/) { print "inside\n"; $hash{$1} = $2; } $line = ; } print +($_ , " -> ", $hash{$_},$/) for (keys %hash); __DATA__ $step1 1 $step2 1 $step3 1