Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Basic I/O #2

by 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



Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
erix .oO( that sounds Boyer-Mooreish )
[Corion]: erix: Yes, but that's mostly for skipping characters you'll never read, but this approach skips the problem of needing to load more data while looking at a half-match
[Corion]: I mostly wonder how I can add this "reversal" to my toolchest, and if it's worth it or just clever

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (15)
As of 2016-12-06 15:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (108 votes). Check out past polls.