#! /usr/bin/perl -w use strict; my @letters = qw(a b c d e); #'a'..'e' also works, #but I didn't want to add #a red herring ;-) print ' $_ | $r | $.'."\n"; for (@letters) { if(my $r = /a/../e/) { printf "%4s |%4s |%4s\n", $_, $r, $.; } $.++; # ok, this is silly # but I'm making a point ;-) } print "\n", ' $_ | $r | $.'."\n"; while () { chomp; if(my $r = /a/../e/) { printf "%4s |%4s |%4s\n", $_, $r, $.; } } __DATA__ a b c d e #### $_ | $r | $. Use of uninitialized value in printf at ./r2.pl line 12. a | 1 | b | 2 | 1 c | 3 | 2 d | 4 | 3 e | 5E0 | 4 $_ | $r | $. a | 1 | 1 b | 2 | 2 c | 3 | 3 d | 4 | 4 e | 5E0 | 5