Click here to get back home

Read 20 lines when pressing n for next

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Read 20 lines when pressing n for next s9uzaa 04-29-2008
Posted by Jürgen Exner on May 3, 2008, 4:08 pm
Please log in for more thread options
>> > > > 4. must have subroutine used.
>
>Why do you all just assume it's a homework assignment?

Name one other probably explanation for such an odd requirement within
such an odd task.

>Could it not just
>as well be a simplified work project? I would not be at all surprised if
>this was something handed down by one's boss or project manager, and
>written in a simplified form (which is what one *should* do, no?)

A boss or project manager asking to reinvent the wheel, oooops, sorry,
to rewrite the "more" utility "using subroutines" (whatever that is
supposed to mean)? Yes, of course it can be. Just like it is possible
that all the molecules of the chair I am sitting on will move 1m to the
left and I'll drop to the ground. Since Heisenbert we know that that is
possible.
Get real! Any boss or PM asking for something like that will survive
only until his superior finds out.

jue

Posted by Ted Zlatanov on April 30, 2008, 2:15 pm
Please log in for more thread options
On Tue, 29 Apr 2008 18:21:12 -0700 (PDT) s9uzaa@gmail.com wrote:

s> I would like to write a perl script with the following criteria match.
s> 1. open any text file taken the name from the command line.
s> 2. read top 20 lines and stops, then
s> 3. ask to press letter "n or p" (for next/previous) to print next or
s> previous 20 lines.
s> would appreciate any kind of help.
s> 4. must have subroutine used.

perl -e'sub { exec less => -20 => @_}->(@ARGV)' FILE1 FILE2 ...

Unfortunately this uses SPACE or `f' instead of `n' to advance to the
next 20 lines, but I think it meets all the other criteria.

Good luck!
Ted

Similar ThreadsPosted
filehandle, read lines July 24, 2007, 5:09 am
Read first few lines from command output July 27, 2005, 1:47 pm
Beginner: read in lines array1 and after keyword array2 July 30, 2006, 7:37 am
How to break the lines in printing to html lines? July 5, 2006, 11:21 pm
perl -pe for blocks of lines instead of single lines September 26, 2006, 1:29 pm
How to filter out lines from a variable that has multi-lines? September 28, 2007, 9:09 pm
FAQ 6.3 How can I pull out lines between two patterns that are themselves on different lines? January 27, 2005, 12:03 am
FAQ 6.3 How can I pull out lines between two patterns that are themselves on different lines? May 14, 2005, 5:03 am
FAQ 6.3 How can I pull out lines between two patterns that are themselves on different lines? July 29, 2005, 10:03 pm
FAQ 6.3 How can I pull out lines between two patterns that are themselves on different lines? September 26, 2005, 10:03 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap