my $infile = $ARGV[0]; infile ($infile); sub infile { open( my $infile, '<', $ARGV[0] ) or die "cannot open file: $!"; # ... #### my $infile = $ARGV[0]; process_file ($infile); sub process_file { my $current_file = shift; # or: my $current_file = $_[0]; open my $FILEHANDLE, '<', $current_file or die "cannot open file $current_file: $!"; # ...