in reply to Creating HTML page

You don't check whether your sysopen() call failed. Do that. Also, why are you using sysopen instead of using plain open?

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

Replies are listed 'Best First'.
Re^2: Creating HTML page
by ganilmohan (Acolyte) on Aug 05, 2008 at 09:15 UTC
    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);
      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
      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.