print "What number?"; chomp($var = *STDIN*); $var1 = "MEANINGLESS TEXT"; $var2 = "ALTERNATIVE TEXT"; $line3 = (However you tell PERL that this is line1 of the "MEANINGLESS TEXT" record block); $line4 = (However you tell PERL that this is line4 of the "MEANINGLESS TEXT" record block); $line5 = (However you tell PERL that this is line5 of the "ALTERNATIVE TEXT" record block); $line7 = (However you tell PERL that this is line7 of the "ALTERNATIVE TEXT" record block); open(FILE, "resultsdata"); while (*FILE*) { if (/$var/ && /$var1/) { print "$var1\n"; print "$line3\n"; print "$line4\n"; if (/$var/ && /$var2/) { print "$var2\n"; print "$line5\n"; print "$line7\n"; } } }