#!/usr/bin/perl -ln use strict; use warnings; BEGIN { @ARGV='assign' } our %hash; $hash{$1}=$2 if /^(\S+)\s+(\d+)/; END { my @msg=qw/FOO 1st 2nd 3rd/; $hash{"\$step$_"} and print $msg[$_] for 1..3; } __END__