Loading ...
Sorry, an error occurred while loading the content.

Re: how to avoid the caching of the executed perl file

Expand Messages
  • Aliet Santiesteban Sifontes
    Tom, thank s a lot, I m going to test it right now, I tell you later. Best Regards
    Message 1 of 9 , Sep 23, 2005
    • 0 Attachment
      Tom, thank's a lot, I'm going to test it right now, I tell you later.
      Best Regards
      Tom Schindl wrote:
      > -----BEGIN PGP SIGNED MESSAGE-----
      > Hash: SHA1
      >
      > Ok. The offending code is this:
      >
      > - --------------------8<--------------------
      > use strict;
      >
      > my $cgi;
      > my %params;
      > # my ....
      >
      > sub getDataFromListCode {
      > $params{"Filtro1"}= "";
      > $params{"Filtro2"}= "";
      > $params{"Filtro3"}= "";
      > $params{"Filtro4"}= "";
      > # .....
      > }
      > - --------------------8<--------------------
      >
      > the real code after registry has loaded it looks like this:
      >
      > - --------------------8<--------------------
      > sub run {
      > use strict;
      >
      > my $cgi;
      > my %params;
      > # my ....
      >
      > sub getDataFromListCode {
      > $params{"Filtro1"}= "";
      > $params{"Filtro2"}= "";
      > $params{"Filtro3"}= "";
      > $params{"Filtro4"}= "";
      > # ....
      > }
      > }
      > - --------------------8<--------------------
      >
      > These are closures to variables and so they won't change their values
      > after the first execution. Couldn't you just move all variables defined
      > before "sub getDataFromListCode {}" inside the sub or another idea is
      > the you make real globals from them using "use vars" or $main::cgi for
      > variable names.
      >
      > Corrected code would look like this:
      >
      > - --------------------8<--------------------
      > use strict;
      > use vars( $cgi, %params );
      >
      > $cgi = new CGI();
      > %params{"bla"} = "blo";
      >
      > sub getDataFromListCode {
      > $params{"Filtro1"}= "";
      > $params{"Filtro2"}= "";
      > $params{"Filtro3"}= "";
      > $params{"Filtro4"}= "";
      > # ....
      > }
      > - --------------------8<--------------------
      >
      >
      > For more information look here:
      > http://perl.apache.org/docs/general/perl_reference/perl_reference.html
      >
      > Generally it's not good practice to use global variables in sub-routines
      > you should pass them to them. If you need globals you should declare
      > them using use vars(). The difference is explained in the url above.
      >
      >
      > Tom
      >
      > Aliet Santiesteban Sifontes wrote:
      >
      >> Tom , at this link you can find the scripts, problematic is Listing.pl,
      >> don't blame me for the bad code, I'm just trying to fix it, is a very
      >> old apps:
      >> http://sflcujae.cujae.edu.cu/perl/
      >>
      >> Tom Schindl wrote:
      >>
      >> Aliet Santiesteban Sifontes wrote:
      >>
      >>
      >>
      >>>>> The problem was solved using
      >>>>>
      >>>>> ModPerl::PerlRun
      >>>>>
      >>>>>
      >>>>>
      >> I'd suggest to get better performance to switch back to
      >> ModPerl::Registry. You have shown us many lines of code but not the one
      >> which shows how your problem is created. I suppose you are creating a
      >> closure to $cgi and that's why it is cached and not renewed on every
      >> request.
      >>
      >> Show us the lines where you are defining variables like $cgi and we can
      >> proof whether I'm right or wrong.
      >>
      >> Tom
      >>
      >>
      >>>
      >>>
      >>>
      >
      > -----BEGIN PGP SIGNATURE-----
      > Version: GnuPG v1.4.0 (GNU/Linux)
      > Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org
      >
      > iD8DBQFDM7PhkVPeOFLgZFIRAotOAJsEeytqL9TnYZcB1aCN/MqM+u24swCePsNy
      > 0I6urn4IPpkKm3jHwGFAgCI=
      > =ph6u
      > -----END PGP SIGNATURE-----
      >
      >
      >
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.