in reply to How to retrive value from session using Perl CGI.
I don't know where you got that code from, but it is some butt ugly code.
The good news is that if you want to get down with perl, there are much more elegant places to see code.
Have you seen the CGI::Session and CGI cpan pages?
I suggest you print them out and staple them together. Have them besides you when you code.
One tip: You have a lot of print statements thrown about here and there, this is mixing up feedback with logic. You should separate them. At one section of your code you should work out logic, what you are trying the computer to have do for you. There should be no 'result', feedback. Yet. You could store everything in a variable. ..
#!/usr/bin/perl # this code has not been tested/debugged use Time::Format 'time_format'; use CGI; use strict; use warnings; # logic part.. where you establish values solve problems my $d = time_format('mm/dd/yy',time); my $cgi = new CGI; # output part... better to separate # for your own organization's sake my $html = $cgi->header . $cgi->start_html . $cgi->h1('hello') . $cgi->p("Today is $d"); # now you print print $html; exit;
Which brings be to the other part... CGI can do a lot more then you think. And you should use that. Look up Ovid for more on that, and why.
It may seem like using those tools instead of just using print is overkill- it's not. In the long run you'll code faster and solve problems.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to retrive value from session using Perl CGI.
by ramesh_ps1 (Initiate) on Sep 12, 2007 at 10:02 UTC | |
by leocharre (Priest) on Sep 12, 2007 at 20:04 UTC |