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

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

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

    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.

        Yes

        User logs on and id is stored to be used later in program/other modules to perform specific actions based on users id.

      This is my exact problem.

      Going back to your post Re^15: global var I think I now understand. You are accessing $manageusers::LoggedOn_user_id from a different script (update_table.cgi ?) from the one that set the value which was presumably manage_users.cgi. As you found that doesn't work.

      One solution would be retrieve it directly from the CGI::Session object.

      my $dbh = manageusers::OpenConnection(); warn("update_tables.cgi after open connection"); # Dispatch to proper action based on user selection my $count = 0; my $query = new CGI; my $cgiURL = CGI::url(); my $action = lc ($query->param('action')); ## changes ## # my $userid_1 = 0; my $session = CGI::Session->load( "driver:MySQL", $query, { Handle => $dbh } ); my $userid_1 = $session->param("user_id");
      poj

        That would be going in a circle.

        User with 7 day cookie set goes to log on. Cookie recovered, session checked against session database to verify user. User_id recovered from session and stored in LoggedOn_uder_id to be accessed in update_tables.cgi to access other data from database which uses the id as key

        Recovering the id from session in the other modules would just be redundant

        I have never had such a problem in other languages

        I will check out using "storable" as soon as localhosting resolved issue. Error says it is not installed on their system but list of installed modules says it is.