# put data into an array open(FH, "file"); my @in=; close (FH); # loop through array for (my $i=0; $i<@in; $i++) { # if the line contains use... if ($in[$i] =~ /USE/) { # skip the line that had use in it, and loop # until the array is done or USE is encountered for ($i++; $in[$i] =~ /USE/ && $i<@in; $i++) { print $in[$i]; } } }