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

Bareword 'end_form' not allowed when under strict subs. Then when I put single quotes around it the error goes away but the form or table doesn't print. What's wrong with it?
print start_form(-action=>'mail.pl'), table( Tr( td("Name"), td( textfield( -name => 'name') ) ), Tr( td("age:"), td( textfield( -name => 'age') ) ), Tr( td( submit('send') ), ), 'end_form', );

Replies are listed 'Best First'.
Re: bareword problems
by dws (Chancellor) on Aug 05, 2003 at 19:15 UTC
    Bareword 'end_form' not allowed when under strict subs.

    Remove the single quotes and slap a pair of parentheses on it so that Perl knows that it's a function call.    end_form() should do the trick.

    You've got some extra commas in there, but I don't think they're anything more than a style problem.

Re: bareword problems
by Mr. Muskrat (Canon) on Aug 05, 2003 at 19:16 UTC

    How are you loading the CGI module? It works fine for me with: use CGI qw(:standard);

    use warnings; use strict; use CGI qw(:standard); print start_form(-action=>'mail.pl'), table( Tr( td("Name"), td( textfield( -name => 'name') ) ), Tr( td("age:"), td( textfield( -name => 'age') ) ), Tr( td( submit('send') ), ), end_form, );

Re: bareword problems
by chromatic (Archbishop) on Aug 05, 2003 at 19:16 UTC

    It's a subroutine call. Use end_form(), with the empty argument list.

Re: bareword problems
by Wonko the sane (Curate) on Aug 05, 2003 at 19:19 UTC
    To Perl that sort of looks like a bareword, you need to give a bit more of a hint on what your trying to do.

    Change it to:

    end_form(),
    and that should fix your problem.
    Wonko