[thelist] Perl program question

Portman mrport at sbcglobal.net
Sun Jun 11 18:53:57 CDT 2006


Thank you for the reply.

As I said in a previous e-mail, I wrote this script with the help of a 
friend from an existing script. I didn't want to take out too much until 
I knew the program was working and then do it carefully. I suspect that 
the "warn total" part is the original script. I will look at the whole 
thing when I have time and clean it up.  Thanks for the good coding 
practices info.

Riva

Bill Moseley wrote:
>     my $shippingCharge=$shipcost{$selectedState}*$1+5;
>
> what does "warn total = [$1]\n"; show?
>
> What's $1?
>
> Sorry to be so blunt, but that script is really poorly written.  No
> wonder it's hard to see what's not working correctly.
>
> Separate your html generation from your business logic, for starters.
> Get your data into and out of a database.  Write the scripts so they
> can be run and tested outside of the CGI environment.   Validate all
> user data.
>
>     my $deflection=$q->param('deflection');
>     my $freeLength=$q->param('freeLength');
>
>     if ($deflection == 0) {$deflection=1;}
>     if ($freeLength==0) {$freeLength=1;}
>
> How do you know $q->param('deflection') is numeric, a valid range,
> or even defined?
>
>
> If you want to code web applications in Perl take a look at Catalyst, a
> Rails-like MVC framework.  It will help with good coding practices.



More information about the thelist mailing list