|
|
| Just another Perl shrine | |
| PerlMonks |
Basic I/O #2by pedagogues |
| on Nov 17, 1999 at 03:06 UTC ( #996=perlsolution: print w/ replies, xml ) | Need Help?? |
1:
2: # Read lines until a line consisting only of "." is seen.
3: # Then print the lines back out in the opposite order.
4:
5: my @lines;
6:
7: while ( $line = <> and $line ne ".\n" )
8: {
9: push @lines, $line;
10: }
11:
12: foreach ( reverse @lines ) # only reverses the list used by foreach; does not modify the array
13: {
14: print;
15: }
go back to Basic I/O Exercises
|
|