sub man_cfs { my ($cashflow, $valid_ports) = @_; @$cashflow = grep { # only keep the ones whose portfolio_id is not empty. $_->{'portfolio_id'} ne '' } @$cashflow; # loop through the new @$cashflow to do other stuff.