process($data_ref, \@set_up, $template, $fd_out); sub process { my ($data, $set_up, $template, $fd_out) = @_; foreach my $record (@$data) { # ... } } #### my $fd_out; open($fd_out, $what_file); while (<$fd_out>) { # ... } #### my $fd_out = IO::File->new($what_file, 'r'); while (<$fd_out>) { # ... }