?
Solved

View a log file at 50 lines at a time.

Posted on 1998-01-09
11
Medium Priority
?
191 Views
Last Modified: 2008-03-06
I know this is almost the same as the question about 700 lines, but I would like someone to help me have it do more. How do I have it load 50 lines of a document, have it create a button (submit) that I could click on then it load the next 50, and so on and so on.

thanks
0
Comment
Question by:Perl_Man
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
11 Comments
 
LVL 1

Accepted Solution

by:
malec earned 10 total points
ID: 1209528
same thing (almost):

while( <FILE> ){
   push @a,$_;
   next if @a < 50;
#process your 50 lines here

   print <TT;
     <form method="POST">
     <input type="submit" value="Next 50 lines"
     </form>
TT

   @a = ();
  }
  do the rest here
0
 

Author Comment

by:Perl_Man
ID: 1209529
where do i put the file name?
0
 
LVL 1

Expert Comment

by:malec
ID: 1209530
open (FILE, "/usr/people/myfile") || die "Cannot open $!";

while( <FILE> )
{

...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Perl_Man
ID: 1209531
thanks, let me test it out.  then if it works u get the credits.
0
 

Author Comment

by:Perl_Man
ID: 1209532
this is what I have on my site and it gives me an 500 Internal Server Error message (from my browser....

if ($command eq 'ViewFullLog') {
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head><title>View the log</title></head>\n";
print "$body\n";

open (FILE, "/cgi-bin/FullLog.txt") || die "Cannot open $!";
while( <FILE> ){
      push @a,$_;
        next if @a < 50;
        #process your 50 lines here
        print <TT;
              <form method="POST">
              <input type="submit" value="Next 50 lines"
              </form>
        TT
      print "</body></html>\n";
        @a = ();

exit;
}
0
 
LVL 84

Expert Comment

by:ozo
ID: 1209533
print <TT;
should be
 print <<TT;
and the coreesponding TT at the end should be the onle thing on the line
with no blank spaces before or after it.

0
 

Author Comment

by:Perl_Man
ID: 1209534
fix that pert, but still coming up with an internal server error message.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1209535
Does it get the same error when $command ne 'ViewFullLog'?
Do you have a close } on your if?
What's in $body?
What if you change
  die "Cannot open $!"
to
  print "Content-type text/plain\n\nCannot open $!\n</body></html>\n"

and
 <input type="submit" value="Next 50 lines"
should probably be
 <input type="submit" value="Next 50 lines">
0
 

Author Comment

by:Perl_Man
ID: 1209536
Ok $body holds the <body bg=.... text=.... etc.> i know that is  not the problem since it works fine in all of my other scripts and it worked fine before I added this code.  Also I tried change eq, still made no difference (so I changed it back).  I fixed the form error (missing the >). Still no difference.  Also changed the content-type command.  Still no change, still gettign the Internal Server Error..
0
 
LVL 1

Expert Comment

by:malec
ID: 1209537
Are there any print statements before that code fragment? If there are they should be preceded by print "Content-type: text/html\n\n", which should be your first print.
0
 

Author Comment

by:Perl_Man
ID: 1209538
fixed it
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question