print "...\n" my @input; while () { last if /^q$/; push @input, $_; } print reverse @input;