in reply to Re: Creating HTML page
in thread Creating HTML page

Corion, I have tried with the lines you have suggested but still the thml file is NOT created...

print "content-type: text/html \n\n"; #The header
my $outname = 'usr/anil/scripts/myhtml.html';
open HTML, '>', $outname || die "Couldn't create '$outname': $!";
printf HTML "<html>\n";
printf HTML "<head>\n";
printf HTML "<title>My Home Page</title>";
printf HTML "</head>\n";
printf HTML "<body>\n";
printf HTML "

Here we have an HTML page with a paragraph.

";
printf HTML "</body>\n";
printf HTML "</html>\n";
close ($outname);

Replies are listed 'Best First'.
Re^3: Creating HTML page
by davorg (Chancellor) on Aug 05, 2008 at 09:43 UTC
Re^3: Creating HTML page
by FunkyMonk (Bishop) on Aug 05, 2008 at 10:12 UTC
    Others have mentioned your open should be using or, not ||.

    You seem to have lost the leading / from $outname. You should be using:

    my $outname = '/usr/anil/scripts/myhtml.html'; open HTML, '>', $outname or die "Couldn't create '$outname': $!";

    If that still doesn't work, tell us what the error message is.

    Why aren't you using strict and warnings? Always start your Perl programs with

    #!/usr/bin/perl use strict; use warnings;


    Unless I state otherwise, all my code runs with strict and warnings
Re^3: Creating HTML page
by Corion (Patriarch) on Aug 05, 2008 at 09:18 UTC
    open HTML, '>', $outname || die "Couldn't create '$outname': $!";

    This is not what I suggested. I suggested what I suggested for a reason.

    Also, consider using <code>...</code> around your code, so that it renders and downloads nicely.