require 5.006; # needs recent perl for three-argument open my $infile = 'addys.txt'; my @email_addys; { # enter new scope # create a filehandle visible in the current scope local *FH; # open the file for reading, die on errors # three-argument open is safer than two-arg -- # it safely handles filenames that begin with '<', '>', etc. open( FH, '<', $infile ) or die "Couldn't open $infile: $!" ; # process the file, line by line # <> returns undef at EOF, and the loop ends while( defined(my $line = ) ) { chomp $line; # append the current line from the file to an array push @email_addys, $line; } # close the filehandle, processing is complete close( FH ); } # exit scope # FH is not visible here. #### .