my $args = { balance_sheets => \@balancesheets, cashflows => \@cashflows, pnl => \@pn1, # etc. # etc. }; my $F = piotroski($args); my (@dates, @scores); push @dates, $F->{date}[$_]{$co_name} for (0..4); push @scores, $F->{score}[$_]{$co_name} for (0..4); print join(qq{\t}, @dates), qq{\n}; print join(qq{\t}, @scores); sub piotroski { my $args = shift; # # do something with args # my $F = { date => $date_ref, score => $F_SCORE_ref, score_box => $F_SCORE_BOX_ref, roa => $F_ROA_ref, # etc. # etc. } return $F; }