sub print_record { return unless @singlereference; #no work to do @singlereference = sort {$a <=> $b} @singlereference; foreach my $col (@singlereference) { print "$netname $col\n"; } @singlereference =(); #reset array to empty return; }