Adapting perl script to a web environment

E

Emma-O

Hello,

I'm trying to adapt a GNU perl script for using it on a web
environment through CGI.

The script, called textcat, is a language guesser based on n-grams.

This is the source code:
http://odur.let.rug.nl/~vannoord/TextCat/text_cat

And this is the web demo (code doesn't seem to be available, otherwise
I wouldn't ask):
html form: http://odur.let.rug.nl/~vannoord/TextCat/Demo/textcat
cgi: http://wodan.let.rug.nl/vannoord_bin/tc

There's also this code adapted for spam assassin as a pm:
http://spamassassin.rediris.es/full/2.4x/dist/lib/Mail/SpamAssassin/TextCat.pm

I have almost no knowledge of perl but I can understand the code,
since it is quite similar to other programming languages.

Could anyone give some advise to adapt the code for a cgi?

Thanks in advance,
- upierz
 
S

Sherm Pendley

Emma-O said:
I have almost no knowledge of perl but I can understand the code,
since it is quite similar to other programming languages.

Could anyone give some advise to adapt the code for a cgi?

A good place to start learning Perl is:
<http://learn.perl.org>.

The author of CGI.pm maintains a tutorial about it:
<http://stein.cshl.org/WWW/software/CGI/>

Also, if you haven't done so already, you should read the posting guidelines
for this group - they're posted here often.

sherm--
 
E

Emma-O

Sherm Pendley said the following on 13/01/2005 21:42:
A good place to start learning Perl is:
<http://learn.perl.org>.

The author of CGI.pm maintains a tutorial about it:
<http://stein.cshl.org/WWW/software/CGI/>

Also, if you haven't done so already, you should read the posting guidelines
for this group - they're posted here often.

sherm--

Sherm, thanks for the information.

However, I hoped to get something more specific. I don't expect you to
do this for me, just point me to the right direction in this
*particular* issue.

When somebody asks me something more or less concrete about php, for
instance, I try to answer to that - perhaps in a general fashion - but
I'd never say: go and learn php.

:(

I've tried to adapt the code before coming here. I'm here because I
thought that some specific information would help.

Many thanks,
- upierz
 
S

Sherm Pendley

Emma-O said:
However, I hoped to get something more specific.

Well, to be frank your question was a bit too vague for a more specific
answer. I gave it my best guess. :-(

Based on what you've given though, I'd have to say the best approach to
adapting such a script would be to not adapt the script itself at all.
Instead, I'd just write a simple CGI wrapper around it.

In the simplest case that would just be a matter of passing a few command
line switches and reading whatever output came from the script. Perl's
"open" function accepts piped input from other apps, just like a shell
would - see "perldoc -f open" and "perldoc perlopentut" for details.

For a more complex script, there's an Expect module on CPAN that does pretty
much the same thing as the program of the same name. Have a look on
<http://www.cpan.org> to find that.

You said you've been programming for a while in other languages, so I assume
you're familiar with the usual dangers of passing arbitrary user input to a
command line. The same thing applies to Perl that would apply to any other
language in that regard. For more perl-specific security tips, have a look
at "perldoc perlsec".

sherm--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top