Y'know, I should be grabbing some of these ideas for quiz and exam questions. :) That's certainly the oddball kind of thing one of us goofball instructors would ask on an exam. ;)<div><br></div><div>-- b<br><br>
<div class="gmail_quote">On Sat, Oct 25, 2008 at 7:37 AM, Jay Hannah <span dir="ltr"><<a href="mailto:jay@jays.net">jay@jays.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
A friend of mine asked me for this one yesterday.<br>
<br>
<br>
Problem:<br>
<br>
Given STDIN print everything except the first 2 lines and last 4 lines.<br>
<br>
<br>
Solution:<br>
<br>
while (<>) {<br>
push @in, $_;<br>
}<br>
print splice(@in, 2, @in - 6);<br>
<br>
<br>
Note this is a terrible solution with large files (memory hog), but works fine on small STDIN.<br>
<br>
Cheers,<br>
<br>
j<br>
<br>
<br>
<br>
$ cat j<br>
one<br>
two<br>
three<br>
four<br>
five<br>
six<br>
seven<br>
eight<br>
nine<br>
ten<br>
$ cat j | perl j2.pl<br>
three<br>
four<br>
five<br>
six<br>
<br>
<br>
_______________________________________________<br>
Omaha-pm mailing list<br>
<a href="mailto:Omaha-pm@pm.org" target="_blank">Omaha-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/omaha-pm" target="_blank">http://mail.pm.org/mailman/listinfo/omaha-pm</a><br>
</blockquote></div><br></div>