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

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.

Replies are listed 'Best First'.
Re^14: global var
by Anonymous Monk on Apr 08, 2017 at 19:30 UTC
    $manageusers::LoggedON_user_id
    should be
    $manageusers_2::LoggedOn_user_id
    obviously.
Re^14: global var
by Anonymous Monk on Apr 08, 2017 at 20:24 UTC

    two days ago and one day ago both answer this

    Now regarding Re^13: global var this is the output of your posted bug report

    $ perl -I. tultalk 428

    It shows no bug , no problem , no errors, no warnings

    The code you posted doesn't reproduce the problem you want to solve in your real program

    If your real program were the same, then it should have no problem

    But then you say your real program does have a problem

    This is not productive way to solve problems

      You pose a dilemma here. Short and sweet, no error. This part of code shows 0 or undefiend at <-------------------------------

      #! /usr/bin/perl -w use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use strict; use diagnostics -verbose; use warnings; use CGI; use CGI qw(:standard escapeHTML); use CGI qw/:standard/; use lib qw(/usr/local/apache/lib/perl); use vars qw($dataupdatemessage $dataupdatefilemessage ); local ($CGI::DISABLE_UPLOADS, $CGI::POST_MAX); $CGI::DISABLE_UPLOADS = 0; # enable uploads Disable uploads $CGI::POST_MAX = 32 * 1024; # limit posts to 32K max<------NEED + TO LOOK AT THIS LIMIT use lib qw(/home/jalamior/www/httpsdocs/cgi-bin/lib/perl); #use lib qw(/srv/www/cgi-bin/lib/perl); use manageusers qw($LoggedOn_user_id); #Error Handling BEGIN { require 5.004; use CGI::Carp qw(fatalsToBrowser carpout); my $logfile = '/home/jalamior/public_html/httpsdocs/cgi-bin/logs/err +orLog/errorFile.log'; # open LOG, ">>$logfile" or die "Couldn't append to $logfile: $!\n"; # carpout(\*LOG); }; warn("Entered update_tables.cgi"); warn("update_tables.cgi before open connection"); #--------------------------------------------------------------------- +--------------------------- my $htmlMemberDownloadHeader='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML +4.01 Transitional//EN"><html><head><title>Member Data Download Form</ +title>'; my $htmlMemberDataFeedbackHeader='<!DOCTYPE HTML PUBLIC "-//W3C//DTD H +TML 4.01 Transitional//EN"><html><head><title>Member Data Update Feed +back Form</title>'; my $htmlTenantListingFormHeader='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HT +ML 4.01 Transitional//EN"><html><head><title>Tenant Listing Form</tit +le>'; my $htmlheader2 = '<meta https-equiv="Content-Type" content="text/html +;charset=iso-8859-1">'; my $htmlheader3 = '<link rel="StyleSheet" href="/graphics/jala_styles. +css" type="text/css">'; 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')); my $userid_1 = 0; ############################################################### $userid_1 = $manageusers::LoggedOn_user_id; <------------------------- +-------- #$userid_1 = 110;

      The other side of the interface boundary:

      package manageusers; use strict; use diagnostics -verbose; use warnings; use CGI; #use Carp::Always; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use CGI qw(:standard escapeHTML); use CGI qw/:standard/; use Data::Dumper; use Digest::MD5 qw(md5_hex); #use DB_File; # persistent hash database use CGI::Session; use CGI::Cookie; #use vars qw($session_cookie1 $session_cookie2 $login_timeout); #use vars qw($session); use Mail::Sendmail; use Time::HiRes qw(usleep); use Time::Local; 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 &decodeEncryptedPassName &UpdateUserData &GetUserLostData &LogoutUser &GetUserSessionCookie &CheckForAuthorizedUser &Expires $LoggedOn_user_id $attempts $adminaccess &Now &CheckValidLoginChar &CheckValidEmailChar &print_md5_javascript); $VERSION = '0.0.1'; }

      Exports the variable $LoggedOn_user_id

      The error reported is that $LoggedOn_user_id is not exported by manageusrs.

      The short test program does not display that error.

      In my program on the defining side of the interface boundary, I declare our $LoggedOn_user_id = 0; so there clearly should be something to export.

      And later I populate the variable with the desired data

      my $username1 = $session->param("user_id"); warn("username1 : '$username1'"); $LoggedOn_user_id = $username1; warn("Already logged on LoggedOn_user_id : '$LoggedOn_user_id'");

      And at that point, the desired information is in the variable.

        IN the code that does show that $LoggedOn_user_id is not exported by manageusrs. put this in right after your use manageusers qw($LoggedOn_user_id); statement

        { use strict; use warnings; my %wanted; $wanted{manageusers}=1; for my $inc (@INC) { opendir (my $dh,$inc) || warn "Can't opendir $inc: $!"; while (my $file=readdir $dh) { if ($file=~m/(.*)[.]pm$/) { if ($wanted{$1}) { warn 'found:'.$inc.'/'.$file; } } } closedir $dh; } }
        and see what your error log says. Be careful to cut and past all of that code, right click on download and select save file as and cut it all from that file you downloaded. Then do it in your sample program above too, and compare the warnings you get from both, remember order in the error log matters! Cut and paste the warnings from both the sample and the real program back here.

        and saying And later I populate the variable with the desired data is easy, proving it is not as easy. So cut and paste ALL of manageusers::OpenConnection() and ALL of every subroutine it calls to prove that you do set $manageusers::LoggedOn_user_id properly every time and dont set it back to zero somewhere else.

        This part of code shows 0 or undefiend at ...

        No it doesnt

        This is the same as before, you post a fragment of code that does not compile, does not run, does not show the problem

        Maybe it shows the problem on your machine, where the code is complete and compiles and runs,

        but over here on my machine it shows that you posted incomplete code which cannot help you fix your problem

        huck guesses that you're loading the wrong .pm file but thats too generous on his part

        The problem is you dont want to do what is required to solve the problem, which is keep deleting parts of code which have nothing to do with the problem, until you're left with a short piece of code which does reproduce the problem

        But you keep posting fragments and hoping that will help you solve it

        Thats a weird way to ask for help, here is a joke for that

        Q: I'm hungry but there is no food in the refrigerator?
        A: I went shopping the refrigerator is overfull, there is cheese, apples.....
        Q: I looked again, all I found was a bowl of water
        A: Ok show me where you looked
        Q: Here
        A: Thats the toilet bowl in the bathroom, the refrigerator is in the kitchen, follow me
        Q: but the sink is over here next to the water bowl
        A: Thats the bathroom sink not the kitchen sink, kitchen is over here
        Q: but the big sink is over here
        A: Thats the bathtub in the bathroom, kitchen is over here
        Q: I can see myself in the kitchen window
        A: Thats the bathroom mirror, the kitchen window is see through
        Q: but look at all these nice kitchen floor tiles
        A: those are bathroom floor tiles because they're in the bathroom
        Q: but look at this nice kitchen towel
        A: if its in the bathroom its a bathroom towel
        Q: I'm talking about the white paper towel
        A: thats toilet paper paper towels are thicker
        Q: but look at all these little scrub brushes arent they cute
        A: yes the tooth brushes do look cute in the bathroom, they would be weird in the kichen
        Q: ok mom lets eat