Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Welcome to the Monastery
 
PerlMonks  

why isnt it working?

by john1987 (Acolyte)
on Nov 19, 2000 at 01:13 UTC ( [id://42390]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

john1987 has asked for the wisdom of the Perl Monks concerning the following question:

hey im a newbie to cgi and i got the works for it. i tried this script on my computer and it worked, but it didnt work on the web, and i chmoded it and everythin, here it is:
#!/usr/bin/perl <br><br> $add = '152'; print $add / 321 + 4 * $add, "\n";
i wanted to know if i needed to add anything for it to work. please reply.

Replies are listed 'Best First'.
Re: why isnt it working?
by chromatic (Archbishop) on Nov 19, 2000 at 01:18 UTC
Re: why isnt it working?
by autark (Friar) on Nov 19, 2000 at 01:26 UTC
    Yikes! You really got that script to work on your computer ? My perl complains loudly when it reaches the <br><br> part.

    Now, if you either removed that line or put it in within a print statement, it would at least compile :-)

    If you want your program to "work" as a cgi-script you need at least a content-type header

    #!/usr/bin/perl -w use strict; print "Content-Type: text/plain\n\n"; my $add = '152'; print $add / 321 + 4 * $add, "\n";
    And it will not work without 'use strict' or '-w' of course *grin*. And then there are all the other possible errors you might make of course...

    Autark.

      A good answer, but please note that the two newlines at the end are part of the header and not a replacement for the two break tags you had listed. To "web enable" your code you should use the code Autark posted but add the your tags in a print statement, like this:
      #!/usr/bin/perl -w use strict; print "Content-Type: text/plain\n\n"; print "<br><br>\n"; my $add = '152'; print $add / 321 + 4 * $add, "\n";
      But I think it was just part of his formatting inside the code tags...
      thanx a lot for ur help, it was well needed.
Re: why isnt it working?
by AgentM (Curate) on Nov 19, 2000 at 01:55 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://42390]
Approved by root
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.