Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^10: global var

by tultalk (Monk)
on Apr 08, 2017 at 02:02 UTC ( [id://1187448]=note: print w/replies, xml ) Need Help??


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

A previous comment posted code as you suggest. It worked fine when I tested it. I have something screwed up somehow and I can't see it.

Posting question here was hoping for some insight as to why something like this may be occurring.

These are two declarations (same location in manageusers just before first function definition.

our $adminaccess = 0; our $LoggedOn_user_id = 0;

As I said in an earlier response, I can grab $adminaccess in javascript in html page.

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

Replies are listed 'Best First'.
Re^11: global var
by tultalk (Monk) on Apr 08, 2017 at 02:55 UTC

    Declaration: our $LoggedOn_user_id = 0;

    This is line from error log (warns):

    $LoggedOn_user_id = $username1; warn("Already logged on LoggedOn_user_id : '$LoggedOn_user_id'");

    Already logged on LoggedOn_user_id : '428' at /home/jalamior/www/httpsdocs/cgi-bin/lib/perl/manageusers.pm line 287.

    And in the other unit

    use manageusers qw(LoggedOn_user_id);

    Tried different variations of qw(LogggedOn.. and qw($LoggedOn.. Neither worked.

    $userid_1 = $LoggedOn_user_id; warn("userid : '$userid_1' ");

    What I get back is

    <h1>Software error:</h1> <pre>&quot;LoggedOn_user_id&quot; is not exported by the manageusers m +odule Can't continue after import errors at update_tables-development.cgi li +ne 30 BEGIN failed--compilation aborted at update_tables-development.cgi lin +e 30. </pre>

    Mangeusers export

    BEGIN { require Exporter; use vars qw($VERSION @ISA @EXPORT_OK); use DBI; # use vars qw(@ISA @EXPORT_OK); # $ENV{DBI_TRACE}=1; # $ENV{PERL_DBI_DEBUG}=1; @ISA = qw(Exporter); # exported functions our @EXPORT_OK = qw( &OpenConnection &OpenSession &ProcessLoginRequest &ProcessLostDataRequest &LoginUser $LoggedOn_user_id &decodeEncryptedPassName &UpdateUserData &GetUserLostData &LogoutUser &GetUserSessionCookie &CheckForAuthorizedUser &Expires $attempts $adminaccess &Now &CheckValidLoginChar &CheckValidEmailChar &print_md5_javascript); $VERSION = '0.0.1'; }

    Before I was led to use EXPORT_OK. I was at least getting zero in $userid_1

    $userid_1 = $LoggedOn_user_id; warn("userid : '$userid_1' ");
      And in the other unit

      Is this 'unit' the script update_tables-development.cgi or another package ?

      Tried different variations of qw(LogggedOn.. and qw($LoggedOn.. Neither worked.

      Why the .. ? now I'm guessing what you tried.
      If you tried LogggedOn_user_id then obviously that won't work with 3 g's in it

      If you tried LoggedOn_user_id did you have LoggedOn_user_id in @EXPORT_OK? The code shows only $LoggedOn_user_id which is a scalar not a method.

      If you tried $LoggedOn_user_id what error did you get ? I assume the error shown LoggedOn_user_id is not exported by the manageuser relates to the previous try with LoggedOn_user_id
      poj

      :)

      You know how people keep asking you to do the same thing ?

      And they ask again and again and again?

      And you never quite do exactly what they're asking?

      And even when the problem was solved two days ago, you still can't see it?

      The two things are connected

      Now, can you or can you not post 20 lines of code that runs and reproduces the problem (self-contained bug report)?

      No error logs, no fragments, just a small/short, self-contained program, which demonstrates the bug/problem?

      See if you follow the guidelines of How do I post a question effectively?, , and create the "20 line bug report", we can better help you, and you can believe us when we do :)

        You know how people keep asking you to do the same thing ? And they ask again and again and again? And you never quite do exactly what they're asking? And even when the problem was solved two days ago, you still can't see it? The two things are connected Now, can you or can you not post 20 lines of code that runs and reproduces the problem (self-contained bug report)?

        I don't know how to answer you. I ran the little code blocks that were posted and they ran fine with no error.

        Please explain how: And even when the problem was solved two days ago, you still can't see it?

        Tell me again and I will implement "the change" required.

        So a made a little pair of units and the variable is passed.

        #!/usr/bin/perl use strict; use warnings; use manageusers_2 qw($LoggedOn_user_id); print "$LoggedOn_user_id\n";

        And

        #!/usr/bin/perl use warnings; use strict; package manageusers_2; BEGIN { use vars qw($VERSION @ISA @EXPORT); use DBI; # $ENV{DBI_TRACE}=1; # $ENV{PERL_DBI_DEBUG}=1; require Exporter; @ISA = qw(Exporter); # exported functions our @EXPORT_OK = qw($LoggedOn_user_id); $VERSION = '0.0.1'; } our $LoggedOn_user_id=428; 1;

        I made sure the aparameters in my real program were the same

        It failed

        $userid_1 = $manageusers::LoggedON_user_id; warn("userid : '$userid_1' ");

        And the result is:

        update_tables-development.cgi: Use of uninitialized value in concatena +tion (.) or string at update_tables-development.cgi line 66. userid : '' at update_tables-development.cgi line 66. [Sat Apr 8 13:55:38 2017] update_tables-development.cgi: userid : '' + at update_tables-development.cgi line 66.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1187448]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2025-11-08 07:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (65 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.