my @prettybase; my $seen = 0; while () { chomp; my @info = split /\t/; unless ($info[1] == $patient_number) { # Use this to short-cut out of the file once we've found our patient info. last if $seen; next; } $seen = 1; push @prettybase, $_; } # At this point, everything in @prettybase corresponds to the patient specified. # Modify your algorithms accordingly.