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

I've tried to create a form in a following way:
print $query->header(), $query->start_html('XX'); print $query->start_form(-method=>'post', -action=>'program.pl'); print $query->table( $query->Tr( # line 167 $query->td(...) ), ... ); print $query->end_form(); print $query->end_html();
It doesn't work allthough I have done same thing exactly the same way earlier. error.log says Undefined subroutine &main::Tr called at /DOCS/Department/SG/cgi-bin/Projects/projects.pl line 167. So, does anyone have any good guess, what's wrong?
In my script file I've got following specifications
use CGI qw(:standard); my $query = new CGI;

Replies are listed 'Best First'.
Re: Problems with creating a form
by Masem (Monsignor) on Mar 12, 2001 at 19:38 UTC
    Most likely, Tr in $query->Tr shouldn't be uppercase .. all of CGI's functions that I can think of are all lowercase, and this would be an odditiy if just ->Tr was...
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain

      Actually tr is already used, it's the built-in tr///, hence the CGI methid/function is Tr, something that trips everyone (and you!) at least once.

      Update: Aaaarrrghhh! merlyn is right (see below) I always use the function version, and I have been bitten (several times, I'm a slow learner ;--( by it, so I got a little too paranoid. All my apologies to masem.

      RE-Update: after further testing, my first version was right, it _is_ Tr, whether using the function or the method. merlyn is wrong there.

      Re-Re-Update: as the rep of this node go down and the one of merlyn's go up I guess I have to prove my point, so try this and then change Tr to tr ;--)

      perl -e 'use CGI; my $q= new CGI; print $q->Tr, "\n";'

      Other upper-cased function/methods are: Select, Link, Delete, Accept and Sub.

        Not quite. If you use the method version, it's tr. If you use the function version (my preferred), it's Tr. The problem is that the code at the head of this thread is using the method version, but the function capitalization.

        -- Randal L. Schwartz, Perl hacker


        update: I'm wrong. I mis-remembered.
      Actually Tr should be uppercase. I just had a typo in one line: I had written $query-Tr instead of $query->Tr. The error message in error.log wonders me though...