#!/usr/bin/perl #### no strict; # Yuk! no warnings; # Yuk! # s/no/use/gsm; #### my $step1; my $step2; my $step3; my @array1; my @array; my $i = 0; #### open(FILE, "assign"); #### open my $fh, '<', 'assign' or die "hard, but say why (\$!): $!\n"; #### $line = ; while ($line ne ""){ #### while (<$fh>) { ... # or while (my $line=<$fh>) { ... #### chomp($line); if($line =~ /^(\S+)\s+(\d+)$/) { print "inside\n"; $hash{$1} = $2; #### $i++; #### while( ($key, $value) = each %hash) { print "$key +> $value\n"; $key = $value; } #### #!/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__