my @input; while() { chomp; last if $_ eq 'done'; push @input, $_; } print join $/, reverse @input;