On Thu, 29 Nov 2001 at 07:09:10 -0600, Greg Bacon wrote:
> Yesterday, I saw an interesting related exercise. Write a program that
> reads the lines from a file and outputs the middle line. The kicker is
> that you can't use arrays.
You say "file". I unilaterally interpret that as a plain file that I can
have two pointers to.
I assume I'm allowed to use an element of @ARGV.
open$_,$ARGV[0]for F,G;while(<F>,<F>){<G>}die scalar <G>
or this, which doesn't always print the newline at the end:
undef $/;$_=<>;1while s/.*\n([^\0]*)\n.*/$1/;print
... no doubt the RE can be fixed. Back to work ;-)
Ian