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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Raw HTML Code
by davorg (Chancellor) on Aug 05, 2008 at 13:45 UTC

    I'm a little confused here. And I suspect you are too. What, exactly, are you trying to do?

    Is this a CGI program that you want to run from a browser? In that case, it should write its output to STDOUT, not a file.

    Or is this a command line program that is run to generate an HTML page which you will then upload to a web server? In that case, there is no need to print out a CGI header.

    In either case, it's strange that you load the CGI.pm module and then completely ignore it.

    I think that you don't really understand what you're trying to do. Please read a basic introduction to CGI programming.

    --

    See the Copyright notice on my home node.

    "The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg

Re: Raw HTML Code
by swampyankee (Parson) on Aug 05, 2008 at 13:04 UTC

    Oddly, it works for me (I made two fairly trivial changes to the program you listed: I modified the message printed when the open dies and I put the argument for the open in parentheses.

    Then generated code looks like this:

    <html> <head> <title>My Home Page</title></head> <body bgcolor = blue> Here we have an HTML page with a paragraph. </body> </html>

    Just for completeness, this is the code I actually used:

    #!/usr/bin/perl use strict; use warnings; use CGI qw/:standard/; print "content-type: text/html \n\n"; #The header print header; my $outname = "myhtml.html"; open(HTML, '>', $outname) or die "Couldn't create $outname because $! +\n"; print HTML "<html>\n"; print HTML "<head>\n"; print HTML "<title>My Home Page</title>"; print HTML "</head>\n"; print HTML "<body bgcolor = blue>\n"; print HTML " Here we have an HTML page with a paragraph. "; print HTML "</body>\n"; print HTML "</html>\n"; close (HTML);

    Information about American English usage here and here. Floating point issues? Please read this before posting. — emc

Re: Raw HTML Code
by Corion (Patriarch) on Aug 05, 2008 at 12:32 UTC

    What do you expect? You're writing to a file. The file will contain only the HTML you write to it. What do you expect?

    A reply falls below the community's threshold of quality. You may see it by logging in.