in reply to Re^11: 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)?

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 :)

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

    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.
      $manageusers::LoggedON_user_id
      should be
      $manageusers_2::LoggedOn_user_id
      obviously.

      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.