Desmond Coughlan wrote: > Le Wed, Feb 12, 2003 at 02:14:53AM +0000, Desmond Coughlan a écrit ... > > > I post statistics to a newsgroup called news:alt.activism.death-penalty > > once per week, using the 'ngstatistics' script by H. Alex LaHurreau and > > Davide G. M. Salvetti. You can see the script in its entirety here ... > > { snip } > > OK ... no wants to answer me.
Hi Desmond, Well, you are going to have to do the lead work here. this isn't just a concept test--it's a full application, and debugging it is the programmer's job. You will probably want to start by inserting print statements at critical points in the script to see where it is hanging. You also will want to use an existing news application to sample the output from each group and examine it closely. Look for the application which shows the richest header information. When you can isolate some likely areas where problems might be cropping up, post your findings back, and people will help look for solutions. I looked the application over, and it is really a nice piece of work, in some ways. It is well-documented and richly commented, and neatly laid out. Regions of code are also well labeled. Unfortunately, this points to a major limiting consideration. This code is allthrown together in one long script. You can not do serious programming this way. In your code, you have sections marked off as: ###################### ### GRAB SCAN INFO ### ###################### my($current, $from, $to, $articles, $chars, $body_chars, $orig_chars, $day); ... $day = strftime "%a, %d %b %Y", gmtime($^T); ######################### ### PROCESS SCAN INFO ### ######################### In a well designed application, each of the sections marked off in this way should probably be a discrete function. I have a couple scripts of about the same code length, but the scripting content, that code not encapsulated in sub definitions, is: #!/usr/bin/perl5.6.0 -w # Copyright 2002 R. Joseph Newton # Licensed for internal use only by named benificiary institution use strict; # ***************************************** # # EXTERNAL DEPENDENCIES use rjnDate; # comments on purpose use rjnWeb; # ditto # Comments on overall purpose, etc # ***************************************** # # SCRIPTING CONTENT: my %contents = (); ParseQueryLine(\%contents, @ARGV); my %details; RespondToCurrentStage(\%contents); print <<EndOfHTML3; </body> </html> EndOfHTML3 # END SCRIPTING CONTENT # ***************************************** # In my view, even that is a little too much. Most likely, my future Perl applications will have the external dependencies section, then a call to a function with the same name as the file, which will drive all action. I did not realize, when writing this, that %contents was still visible in an effectively global namespace. I won't make the same mistake again. I'd take another look at the processes you are carrying out in your application. Look for binding factors that canuntie blocks of code in discrete functions. You will want to peruse perlsub, perlref, and perlreftut for a better understanding of how to get information into and out of subroutines. Start some debugging experiments, and let us know what reults you get. Please be sure, if you report any errors, to mark in the code, the line number referenced. Keep us posted. Folks on the list do put in a lot of time helping with debugging issues. You have to put in the up-front energy, though, in seeking to isolate sections of your code, or of the overall process, where failure may be occuring. Joseph