in reply to Re^21: global var
in thread global var

The reason i wanted to see if there was more than one copy in the lib stack was because he said it didnt work sometimes, but then when he tried the shorter examples those times it did work. Yes maybe i gave him too much credit in assuming he was loading the newest version into the lib stack at all. But it seemed more likely to me that there were now two versions and they were in different places.

You should go back to the "beginning", his problems with Switch( Switch.pm Failure). It was some of the strangest code ive seen, with a strange subroutine wrapped around the switch call, and returns sprinkled all over. It was the strangeness that intrigued me, and when i figured it out (Re^4: Switch.pm Failure ( CGI::Switch? )) all the artifacts made sense, why the brackets after Switch, why the sub wrapper, and why the returns. SO i have been aware of what kind of code we are talking about since the beginning. I am also aware of his other faults you also have mentioned, which is one reason i have not participated with him of late. But then i thought that maybe he thought he was updating the code in the tree, but it was in the wrong place, so the old code being higher in the lib stack was getting loaded even though he had updated the new code in a lower dir. And when he hand tested the simpler test code the lib stack was different. It was an idea it seems that poj also had. So i asked him to add the full lib search to see if there were two copies of manageusers in the stack.

after all this time he isnt going to change, he may whine that people are being mean to him and he knows what he is doing, but nothing changes.

Replies are listed 'Best First'.
Re^23: global var
by tultalk (Monk) on Apr 23, 2017 at 16:31 UTC

    Fundamental question

    module_1.pm Initializes variable A to 100. Code changes variable A to 300.

    Module_2.cgi uses module_1 but since module_1 is already loaded, it is not loaded again and variable A should be visible to Module_2 as 300.

    Is this correct?

      If this is what you mean, try it

      package module_1; require Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw($A); our $A = 100; 1;
      #/usr/bin/perl # script_1.cgi use strict; use CGI ':standard'; use lib 'path/to/module'; use module_1 qw($A); $A = 300; print header,start_html, h1("\$A = $A"), a( {href=>"script_2.cgi"}, "script_2"), end_html;
      #/usr/bin/perl # script_2.cgi use strict; use CGI ':standard'; use lib 'path/to/module'; use module_1 qw($A); print header,start_html, h1("\$A = $A"), a( {href=>"script_1.cgi"} ,"script_1"), end_html;
      poj

        Exactly

        module_1 initializes $A to 100. script_1 changes #A to 300 and prints it. script_2 loads module_1 and prints $A as 100, the value initialized in module_1.

        This is my exact problem.