gavino wrote:
> I heard perl is good for parsing logfiles and generating
> reports......how does forth handle this area?
One way to answer your own question is to ask why Perl is considered
good for parsing logfiles and generating reports. A moment of research
will tell you the two primary reasons for this is because Perl's regular
expressions are a powerful way to extract patterns from log files. And
on the reporting side, Perl's formatted output and string interpolation
makes generating textual reports pretty easy. Other features of Perl
(such as the ability to implicitly convert between numbers and strings
and hashes) make it pretty easy to slap together code to do that kind of
work.
So now that you know that, you then look at Forth. Forth doesn't
provide regular expressions but you can probably hunt around and find a
regular expression library. The last one discussed in comp.lang.forth
implemented a subset of the pcre syntax and features. Forth does have
pictured numeric formatting which is more primitive than Perl's pictured
formatting, but it's not hard to build the missing functionality if you
need it. Forth doesn't do anything implicitly, so the kinds of nice
conversions between strings and numbers has to be done explicitly in
Forth. Forth's dictionary is conceptually similar to a hash in Perl,
but it isn't a first-class object and generally used in the same way.
So if you're building up a data structure from your logfiles, unless
it's a flat structure (rare in my work, maybe not in yours), you'll be
writing Forth code to do what you want.
So as is usually the case when considering Forth, you have (at least)
three options:
1. Build up all the code you're going to need from scratch yourself and
then build your application. It will probably be faster (if that
matters to you), smaller (if that matters to you), and depending on your
skills, probably more brittle.
2. Find code to do the kinds of processing you want (for example
regular expressions), get it work with your Forth, and then write the
application.
3. Pick a different language that already has the tools you need to
solve the problem. If you already know that language, you're all set.
If you don't, you may have to learn it.
> Does anyone here ever use gforth or another open forth to parse
> logfiles?
I'm sure they do. The critical questions to ask anyone who says yes:
1. How are the source logfiles structured.
2. What kind of processing is done for the reports.
3. How sophisticated is the output of the report.
Take these answers and then compare to the kinds of logfiles you intend
to work on. If you find that their work is similar, then Forth may be a
good choice for you, especially if you can get the other person's code
to learn from. If however you find the logfiles you want to parse or
the reports you want to generate are more complicated, then you may
benefit from ignoring Forth and looking at other tools.
> While I am at it I know i asked this before but how about a good cgi
> pacakge for forth?
>
> Does one exist?
Probably. You should probably specify what you're looking for in a
"good CGI package." You should also spend some time to understand the
limitations of the CGI model and why most non-trivial web applications
don't use it anymore.


|