Adapting perl script to a web environment

Discussion in 'Perl Misc' started by Emma-O, Jan 13, 2005.

  1. Emma-O

    Emma-O Guest

    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
     
    Emma-O, Jan 13, 2005
    #1
    1. Advertising

  2. 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
     
    Sherm Pendley, Jan 13, 2005
    #2
    1. Advertising

  3. Emma-O

    Emma-O Guest

    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
     
    Emma-O, Jan 13, 2005
    #3
  4. 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
     
    Sherm Pendley, Jan 13, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeffrey
    Replies:
    2
    Views:
    6,759
    Jeffrey
    Oct 16, 2003
  2. Steve Chatham

    adapting old asp page to new

    Steve Chatham, Oct 16, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    342
    Steve Chatham
    Oct 16, 2003
  3. Chris Leffer

    Problems adapting CSS

    Chris Leffer, Nov 23, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    1,030
    Chris Leffer
    Nov 23, 2005
  4. Jeffrey Barish

    Adapting code to multiple platforms

    Jeffrey Barish, Mar 12, 2005, in forum: Python
    Replies:
    6
    Views:
    324
    Peter Hansen
    Mar 14, 2005
  5. Keith

    Adapting the Lucene Demo

    Keith, Oct 22, 2007, in forum: Java
    Replies:
    0
    Views:
    352
    Keith
    Oct 22, 2007
Loading...

Share This Page