Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Perl & HTML

  • 20-05-2007 8:52pm
    #1
    Closed Accounts Posts: 2,980 ✭✭✭


    Hey,

    I am embarking on a Bioinformatics project using Perl as the programming language. I know how to embed the HTML code into the Perl program itself but what then is needed for the program to be usable on the web?

    Does the server-machine hosting the website just need to have Perl installed itself? ... ...or will the web browser (say, IE or FireFox) run it themselves?


    Take care,
    Kevin.


Comments

  • Registered Users, Registered Users 2 Posts: 4,276 ✭✭✭damnyanks


    Perl just has to be installed on the host machine.


  • Registered Users, Registered Users 2 Posts: 5,335 ✭✭✭Cake Fiend


    The server will run it and hand over the output to the client browser. In order for this to work, the user account that the web server runs under will need execute permissions on the perl script, and you'll probably have to tell the web server to allow itself to run it (e.g. using the 'ScriptAlias' directive in Apache).


  • Closed Accounts Posts: 2,980 ✭✭✭Kevster


    Nice one, as they say. Thanks.


  • Registered Users, Registered Users 2 Posts: 1,393 ✭✭✭Inspector Gadget


    This thing of wrapping a web interface around an ordinary program (of whatever language) is known as CGI or Common Gateway Interface - maybe it'd be worth your while doing a Google/Wikipedia search?

    Gadget


  • Registered Users, Registered Users 2 Posts: 2,934 ✭✭✭egan007


    The web server should have perl installed (which it probably will if it's not windows) and have cgi configured (which it probably will if you are paying for webhosting space)
    create a file as below: save as index.cgi inthe cgi-bin directory of your webserver. chmod it 755

    #!/usr/bin/perl

    print "Content-type: text/html\n\n";
    print "Hello Online World";
    Print "<table><tr><td>This is a one cell table in perl</tr></td></table>";

    go to http://yourwebsite.domain/cgi-bin/index.cgi

    Hello Online World
    This is a one cell table in perl


  • Advertisement
  • Closed Accounts Posts: 2,980 ✭✭✭Kevster


    Hey,

    Yes, I briefly touched on CGI a few years ago when in college. I really need to get this web-hosting thing sorted before I begin the project. I've been on Geocities for about 10 years but just checked it and they don't appear to support Perl / CGI. I currently have no Unix account anywhere either to test it.


    On another note, how is Javascript handled while being embedded in Perl?

    Kevin.


  • Registered Users, Registered Users 2 Posts: 1,393 ✭✭✭Inspector Gadget


    Kevster wrote:
    On another note, how is Javascript handled while being embedded in Perl?

    Except for very specific circumstances (i.e. if your web server understands it natively), it isn't.

    This is a very common mistake when writing CGI scripts (and "active" web pages in general) - where people get confused between "server side" and "client side" scripting. Essentially, the things to remember are:

    1) Your browser doesn't understand Perl; and
    2) Unless you're using a recentish IIS server, your web server doesn't understand Javascript. Even when it does, it doesn't present certain key objects (for example, the Window object) as they make no sense from a server-side context.

    Your perl code or whatever is tasked with the job of producing valid HTML output - this may or may not include Javascript, that's your choice. However, what the Perl spits out must be (as far as the server goes) the "finished article" - any processing that requires server-based resources - files, databases, whatever - must be done before this program finishes (with the exception of anything pulled from the server using AJAX, but that's another tale for another day).

    Then, when the web browser receives this output, it neither knows nor cares about its origins - whether it's something you wrote in Notepad, put together in Dreamweaver or is the output from a computer program, it can't tell, as there's no evidence of Perl or any other server-side language in there - all it sees are the fruits of that program's labour - its output(s).

    If the HTML is valid, and correctly written, then you'll get the output you want; if not, well, you get the idea. If you want Javascript to be run in the browser, it has to get into the Perl code's output somehow; there are a variety of methods for this.

    Hope this helps,
    Gadget.


  • Closed Accounts Posts: 2,980 ✭✭✭Kevster


    That's very interesting; thanks for that. I think I'll just have to find a good web-server first (maybe purchase my own domain) and then begin programming. From there I'll figure something out for the J'script.


    Kevin.


  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    Just out of interest, is there any particular reason why you must use Perl, is it specified by a customer ect?? Perl (and CGI in general) have always had a number of security concerns around them, I'm not sure how much of an issue this is in reality.

    There are a number of different options, which I'm sure you know about...

    If your looking for cheap hosting look at black-night, domain name + a years hosting for about €50/year :-) I'm not sure if they support Perl, they definitely support PHP and MySQL.


  • Users Awaiting Email Confirmation Posts: 351 ✭✭ron_darrell


    Just out of interest, is there any particular reason why you must use Perl, is it specified by a customer ect?? Perl (and CGI in general) have always had a number of security concerns around them, I'm not sure how much of an issue this is in reality.

    There are a number of different options, which I'm sure you know about...

    If your looking for cheap hosting look at black-night, domain name + a years hosting for about €50/year :-) I'm not sure if they support Perl, they definitely support PHP and MySQL.

    Have to agree with DD here. If you can perhaps IIS and ASP might be an easier route to travel.

    Javascript can be embedded in a PERL script as text i.e. Print "<scr"."ipt>alert('test');</script>"; so outputted to the browser for client side interaction. You cannot however make the javascript and PERL or ASP 'talk' to each other in anything but the most basic way (i.e. use the javascript to update hidden fields in a form and submit or edit the browser location and redirect). As DD pointed out javascript is really designed for client side interaction and PERL / ASP are server side.

    Blacknight is good and you could also try hosting365.com. They have some very good deals for both windows and UNIX servers.

    -RD


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    Just out of interest, is there any particular reason why you must use Perl, is it specified by a customer ect?? Perl (and CGI in general) have always had a number of security concerns around them, I'm not sure how much of an issue this is in reality.
    CGI is not a programming language but a way for the web server to communicate with server scripts/apps.
    O'Reilly has books on Bioinformatics which might have influenced the decision to use perl. As a fan of perl, I love it's regular expressions and text handling. I will admit that PHP can be easier in some HTML generation aspects.

    OP, you don't need to buy web hosting just yet. You can install the Apache web server, perl, PHP etc on your own computer. You'd have a web server which you could interact with. When you need to demo the thing to others you can either put your computer on the network or look at hosting.
    Working on your own computer (let's assume a laptop) means you can continue to work and test when not connected to the internet.


  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    daymobrew wrote:
    CGI is not a programming language but a way for the web server to communicate with server scripts/apps.
    O'Reilly has books on Bioinformatics which might have influenced the decision to use perl. As a fan of perl, I love it's regular expressions and text handling. I will admit that PHP can be easier in some HTML generation aspects.

    OP, you don't need to buy web hosting just yet. You can install the Apache web server, perl, PHP etc on your own computer. You'd have a web server which you could interact with. When you need to demo the thing to others you can either put your computer on the network or look at hosting.
    Working on your own computer (let's assume a laptop) means you can continue to work and test when not connected to the internet.

    I'm well aware that CGI is not a programming language.... I was expressing the fact that any program which uses CGI to access it can be venerable from a security point of view.

    Basically CGI re-directs the parameters sent to a web browser link ( "?do=newreply&p=53291050" ), to the "standard in" of the program/script ( the program can be written in an language which can read from standard in and write to standard out, eg perl, C, C++ )....


  • Closed Accounts Posts: 2,980 ✭✭✭Kevster


    Hey,


    Thank you all for your replies - All are helpful to some degree. This isn't a commercial project; it's just a project for an Honours Degree that will be due in 2008. I'm just making an early start to it. I began Computer Science in 2000; left after third year to do a cert in Applied Biology; and, now that the cert is finished, I'm returning to finish off the Computer Science degree.


    daymobrew is correct: my decision to use Perl was based on books I saw on O'Reilly's website. I subsequently bought two books ("BLAST" and "Beginning Perl for Bioinformatics") and both books use Perl scripts throughout. Apparently, Perl is the most common language used in Bioinformatics.


    I'll check out hosting365 and blacknight.


    Take care,
    Kevin.




    Edit: What do ye make of this package?

    http://www.hosting365.com/hosting-lin-personal.php

    If I did use that, could I simply access it through PuTTY and WinSCP?


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Dunno if hosting365 allow shell access, I think it might all be web based.


  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    Kevster wrote:
    Edit: What do ye make of this package?

    http://www.hosting365.com/hosting-lin-personal.php

    If I did use that, could I simply access it through PuTTY and WinSCP?
    If you register your project on Sourceforge you will get shell access, though (AFAIK) your project would have to be open source.
    I still think that a local web server is the best (and obviously cheapest) short term option.
    I'm well aware that CGI is not a programming language
    I was probably being overly sensitive to what I misread as a dismissal of perl.


  • Users Awaiting Email Confirmation Posts: 351 ✭✭ron_darrell


    daymobrew wrote:
    CGI is not a programming language but a way for the web server to communicate with server scripts/apps.
    O'Reilly has books on Bioinformatics which might have influenced the decision to use perl. As a fan of perl, I love it's regular expressions and text handling. I will admit that PHP can be easier in some HTML generation aspects.

    OP, you don't need to buy web hosting just yet. You can install the Apache web server, perl, PHP etc on your own computer. You'd have a web server which you could interact with. When you need to demo the thing to others you can either put your computer on the network or look at hosting.
    Working on your own computer (let's assume a laptop) means you can continue to work and test when not connected to the internet.


    IIS and ASP have extremely easy to use regexp functions and text manipulation subroutines built in. I honestly can't see much of a difference between PERL and ASP. Is it a Win/UNIX thing??


  • Registered Users, Registered Users 2 Posts: 5,335 ✭✭✭Cake Fiend


    Perl (and CGI in general) have always had a number of security concerns around them

    You could say the same about PHP.


  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    Cake Fiend wrote:
    You could say the same about PHP.

    I would actually be more concerned that CGI uses executable / scripts in a way which they were not intended to be used, ie injecting the request string into standard in of the program. Different scripting languages / executables will all deal with this differently, using different low level libraries, hence it's very easy to inject in a request which will cause problems.


Advertisement