http://www.perlmonks.org?node_id=1187354


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

our $LoggedOn_user_id = 0;

Initializing variable. Later modified with data I want to share to other unit,

Unit? Module? same difference, is it not?

No on the var names being duplicated. Did multiple searches. Only one declaration with values loaded at different locations in program.

This whole program is for a landlord association. Member logs on. Drill down to their status which is loaded into dataset displayed on form (using their unique id passed with $LoggedOn_user_id to the unit generating/displaying dataset. Display includes the number of tenants associated with this member. Next step is to drill down with click on that number to pull up another dataset of all tenants to display.

When I manually set value in calling unit:

#$userid_1 = manageusers::LoggedOn_user_id; #$userid_1 = $manageusers::LoggedOn_user_id; #$userid_1 = $LoggedOn_user_id; $userid_1 = 428;

It of course works fine.

Have another global

$adminaccess = ($username1 eq "admin");

To activate/inactivate menu items depending on login status using javascript in webpage. Logout succeeded form into iFrame deactivates menu through messaging.

<script type="text/javascript"> var adminflag = $manageusers::adminaccess; </script>

Passing variables not new.

Replies are listed 'Best First'.
Re^7: global var
by poj (Abbot) on Apr 07, 2017 at 13:29 UTC
    Unit? Module? same difference, is it not?

    Sorry to be so pedantic but it may be relevant to solving your problem. When you said in your post

    I have global var in main unit:
    @EXPORT = qw( $LoggedOn_user_id $VERSION = '0.0.1'; } our $LoggedOn_user_id;
    do you mean that code is in the 'main' part of package manageusers. At the top maybe before the subroutines declaration ?

    poj