#!/usr/bin/perl use My::Package; # only loop through lines with "30 <= $key <= 70" my $nextrow = itter_maker(30,70); while (my ($num,$dataref) = $nextrow->()) { ### do stuff }