use strict; # never go by without it! ;) rint "Enter your data and then it will print out in reverse order.\n"; my @input; while (){ chomp; last if m/done/i; # quit this loop if input # matches (case insensitive) the word 'done'. push @input, $_; # otherwise, add the word to the list } # Use 'for' loop instead of while if you need to # access array elements via an index variable. for (my $currentline = 1; $currentline <= scalar @input; $currentline++) { my @words=split(/ /,$input[$currentline - 1]); #@words=reverse(@words); $input[$currentline - 1]=join(" ",@words,"\n"); } @input=reverse(@input); print(@input); #### while(){chomp;last if m/done/i;push @a, $_;}print@a; #### $"=q;grep;;$,=q"grep";for(`find . -name ".saves*~"`){s;$/;;;/(.*-(\d+)-.*)$/; $_=["ps -e -o pid | "," $2 | "," -v "," "];`@$_`?{print"+ $1"}:{print"- $1"}&&`rm $1`; print$\;}