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

i have an html file saved as a text file... let's say header.txt which cotains just plain html headers <head> and <body>. now i have a script that opens this file with this code.
open(H, "header.txt"); @header = H; close @header;
then i print the header out
print @header;
but instead of displaying the html header i recieved this annoying error message:
#-----------
In string, @forminputs now must be written as \@forminputs at ./login.cgi line 235, near "});
#separate the different form-inputs
@forminputs"
#---------- now i don't know what's wrong with that??? help me on this guys..... thanks in advance.

Replies are listed 'Best First'.
Re: @forminputs annoying error
by GridMonk (Acolyte) on May 09, 2000 at 11:01 UTC
    I get this kind of error when I forget to escape an '@'
    in quotes (like $email = "me@mydomain.com"; )

    The error does not occur when I escape the ampersand,
    as in $email = "me\@mydomain.com";

    Do you have an ampersand in quotes anywhere in your code?

    Not sure if that is your problem or not, but...

    A monk asked his teacher,
    "What did old Masters attain when they entered the ultimate stage?"
    "They were like burglars sneaking into a vacant house," the teacher replied.

        Try using no quotes around the HTML.
        Just print << HTML;

        .... ?

Re: @forminputs annoying error
by BBQ (Curate) on May 09, 2000 at 07:34 UTC
    You mean apart from that @header is not equal to @forminputs?
    Check and see where are you defining @forminputs...

    It would help if you posted a bit of your original code, maybe from lines 230 through 240...

    #!/home/bbq/bin/perl
    # Trust no1!
      thanks but i think i found my mistake.... i have this line... print<<"EOT"; .... couple of html codes here .... EOT; -> this is the error it should be EOT only. but it does'nt make sense, PERL display's an error which is somehow not related to the real error. thanks anyway
        Beleive me when I say that it probably makes sense. 99% of the times that I catch myself saying things like "Stupid machine, its not supposed to!", I'll be biting my tongue later on with a big Homer Simpson "DOH!". Perl isn't tricky, its just flexible. Once you get past that stage then you'll be laughing at your own mistakes and making a habit of runnin -c.

        In the meanwhile... Each person has his/her own method of defining HTML, but I like doing the following:
        my $variables = '1 2 3'; my @arrays = (4, 5, 6); my $html = qq{ <html> <head> <!-- your head stuff --> </head> <body etc, et al> More stuff with <font face="Verdana, Arial, Sans-Serif">$variables and + @arrays</font> and things of the sort. </body> </html> }; print $html;
        I rarely use { or } characters in my HTML, and even if I do, they are usually in Javascript or CSS which get imported as .js or .css files, so I never have to worry about literalizing(?) any special characters. I hope that helps as a future suggestion.

        #!/home/bbq/bin/perl
        # Trust no1!
        Sometimes that extra semicolon can really mess you up...

        You must have had another EOT somewhere in the file, because it should have given you one of these: Can't find string terminator "EOT" anywhere before EOF at ... So between the first terminating EOT and the second terminating EOT you had the @forminputs variable and perl thought you wanted to print the variable name along with all the other code in between.

        That's why it's helpful to give your here-document labels different names each time, like:

        print <<EOT1; EOT1 print << EOT2; EOT2
        That way if you accidentally put a semicolon on the end of one you'll immediately know where to look because you'll get the error above instead of some other crazy errors.
Re: @forminputs annoying error
by Novician (Novice) on May 09, 2000 at 12:12 UTC
    GridMonk is most prob right.
    u need to have an escape key such as "\" for the char @

    The char "[" and "]" too needs to have an escape key in the front <br>

    As a html format, @ is okay.
    but when it comes to perl, it will think that you are refering
    to an array, because of the @ char.

    Put a "\" in front of every @ char and all should be fine :)
RE: @forminputs annoying error
by Anonymous Monk on May 09, 2000 at 16:28 UTC
    If you open "H" should you not be closing "H" rather than "@headers"?
Re: @forminputs annoying error
by raflach (Pilgrim) on May 09, 2000 at 21:26 UTC
    You can use <code> command to make your code show up properly... currently it looks like you are saying:
    @header=H;
    instead of:
    @header=<H>;
    This shouldn't even begin to work, at least as I understand perl.
    You are also as noted above, never closing the H filehandle.
    This won't really cause you any problems normally, but closing @header doesn't make any sense at all.
    Of course I could be totally misinterpreting what you're trying to do.