in reply to Still blurry on variables for filehandles

Indirect Filehandles are discussed in perldoc perlopentut. The documentation for open may also be useful.

So your code should look like:

use strict; open(my $foo, "<data.txt"); while(<$foo>){ chomp; print "Saw $_ in data.txt\n"; } close $foo;

For hints on lexical variables, you might try "Coping with scoping"