Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Adapting perl script to a web environment

Reply
Thread Tools

Adapting perl script to a web environment

 
 
Emma-O
Guest
Posts: n/a
 
      01-13-2005
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/...sin/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
 
Reply With Quote
 
 
 
 
Sherm Pendley
Guest
Posts: n/a
 
      01-13-2005
Emma-O wrote:

> 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--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
Reply With Quote
 
 
 
 
Emma-O
Guest
Posts: n/a
 
      01-13-2005
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

 
Reply With Quote
 
Sherm Pendley
Guest
Posts: n/a
 
      01-13-2005
Emma-O wrote:

> 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--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 8.34 I {changed directory, modified my environment} in a perl script. How come the change disappeared when I exited the script? How do I get my changes to be visible? PerlFAQ Server Perl Misc 0 03-12-2011 11:00 AM
Problems adapting CSS Chris Leffer ASP .Net 3 11-23-2005 06:51 PM
adapting old asp page to new Steve Chatham ASP .Net 0 10-16-2003 04:53 PM
Adapting onBlur functionality of javascript in ASP.net?? Jeffrey ASP .Net 2 10-16-2003 06:48 AM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM



Advertisments