Hi John,

There are a variety of issues with this, so I'll take it from the top, but starting 
with the issue
with you are concerned.  I hope you don't take any of this personally, as it's just 
intended to be
helpful:

>print $q->endform;

This does indeed print the hidden field that you are concerned with.  Here's a 
solution:

print "</form>"; 

Frankly, I have no idea why that works, or why the hidden field is printed in the 
first place. 
I've read through much of the CGI.pm code, but this is one that I have never 
encountered.

> use CGI qw(:standard :all *table);

You're importing a bunch of functions into your namespace, but you use the object 
oriented
interface ($q->...).  You can drop the import as it's irrelevant and will slow things 
down.  Just
have "use CGI;".  

However, on closer inspection, I realize that you appear to have mixed both the 
function and
object oriented interfaces.  This will merely cause confusion for maintenance 
programmers down the
road.  You should stick with one interface or the other.  From what I see with your 
code, it would
be easier to switch the function calls to object calls:

center() becomes $q->center()
b()      becomes $q->b()
h3()     becomes $q->h3()

And so on...

This is an issue because CGI.pm has to do a lot of work to import those functions into 
the calling
namespace.  Since this module already has a lot of overhead, this is simply extra, 
needless work
if you are using the object oriented interface.

> foreach ($q->param) {
>     $REQUEST{"$_"}=$q->param("$_");
> }

I assume that you know your form better than I do, but are you aware that the above 
snippet will
only return the first value for a param if that param has several values?  For many 
forms, this
will not make a difference.


> sub BuildForm {
> use strict;

Two things here:

1.  It really helps if you indent the code in a sub.  Indentation gives on an 
excellent view of
how things are arranged and scoped.  Just glancing at your code, I can't tell where 
the sub ends
(or if it even ends in the snipped you sent.  Indenting is a Good Thing.

2.  "use strict" is not needed here.  This pragma is lexically scoped.  Thus, it will 
be in effect
in the entire scope of where it's declared.  This means that having a 'use strict' at 
the top of a
program will affect the entire file (even across package boundaries) in which it's 
present.

>     center(h3('TechDirect Estimates'));

$q->center($q->h3('TechDirect Estimates'));

> print center(font({-size=>3},'Fiscal Year'),

print $q->center($q->font({-size=>3},'Fiscal Year'),

> #print start_table;
> print "<table>\n";
>
> [snip]
>
> foreach (sort keys %ids) {
>     print Tr(
>             td({-align=>'RIGHT'},$ids{$_}{label},b(':')),
>             td({-align=>'LEFT'},
> textfield(  -name=>$ids{$_}{name},
>                                 -default    =>$ids{$_}{defa},
>                                 -size       =>$ids{$_}{size},
>                                 -maxlength  =>$ids{$_}{size})),"\n");
> }
> print "</TABLE>\n";

The above code for printing a table is something that I see a lot in code.  This 
happens because
of the way that that tables need to be built.  Here's a somewhat cleaner, object 
oriented method
of building it, assuming that you've already created the %ids hash:

my $table = '';
foreach (sort keys %ids) {
    $table .= $q->Tr(
              $q->td({-align=>'RIGHT'},$ids{$_}{label},$q->b(':')),
              $q->td({-align=>'LEFT'},
              $q->textfield( -name      => $ids{$_}{name},
                             -default   => $ids{$_}{defa},
                             -size      => $ids{$_}{size},
                             -maxlength => $ids{$_}{size})),"\n");
}
print $q->table( $table );

There are more function orient calls, but I think this should give you a good feel for 
it.

Cheers,
Curtis Poe

=====
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Reply via email to