Hi Ramesh.

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.


In reply to Re: How to retrive value from session using Perl CGI. by leocharre
in thread How to retrive value from session using Perl CGI. by ramesh_ps1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.