my $current_elem = 0; sub getnext { $array[$current_elem++]; } ... $bcp->config(INPUT = \&getnext, OUTPUT = 'db.dbo.info_tbl');