in reply to Re^4: Sessions Questions
in thread Sessions Questions

My response about what was in %query was based on the line above

LoginUser($dsn,$sql_username,$sql_password,$sql_user_table,$sql_sessio +n_table,$passhash,$sessionhash,$uvId,$username,$ipaddress);
that i took to be the call to this subroutine.I had counted the args and determined it was even so your "even-sized list expected" message made me wonder, so I searched other posts of yours and found much to my surprise that that the actual calling code seems to be
my ($result, $login_timeout) = LoginUser($query);


A hash, (something starting with a % sign, or used as $something{...}, or $something->{...}) can be thought of a special array with a even number of elements and the odd numbered elements have special magic associated with them. This allows you to assign an list to them like %hash=('a','b'); or often seen as %hash=(a=>'b');. A reference to an @array is seen as a list, and here @_ is an array of the arguments to the call, so %query=@_; qualifies as assigning a list to a hash. but the list needs to have an even number of items in it to properly make the hash work. when use warnings; is in effect you get an warning if a list assignment is made to a hash and the number of items in it is not even, as you now have seen. Warnings do not stop the program tho.

I still stand by my assertion that you do not understand what is in %query, in a similar call
use CGI; my $query=new CGI; test($query); sub test { my (%query)=@_; use Data::Dumper; print Dumper(\%query); }
Dumper shows
$VAR1 = { 'CGI=HASH(0x3f7e24)' => undef };
Which is not what you expected at all is it? Based on seeing that the actual call is
my ($result, $login_timeout) = LoginUser($query);
and that you never use the %query hash i suspect that when you said my (%query) = @_; you really wanted my ($query) = @_; That sets the localized scalar variable $query to the first argument of the call rather than trying to set the hash %query to the entire argument list. It also matches your call better and creates a localized $query variable to use in the LoginUser subroutine based on the arguments to the call rather than using the $query variable set somewhere else.

as i noted warnings do not stop execution and i dont know what you mean by "derails code to determine if already logged in"

as to why "the warn( in my cgi scripts do not print in the error log" i cannot answer, mine do, and a google search has produced no further answers either.

as you see debugging by proxy can be a real pain, even more so for me when you only release code in little pieces, spread across many threads. I understand your frustration, do you understand mine?

I understand debugging old code, both of mine and that from someone else. i stand by my previous statement "You need to step back and look at what is really going on, not what you think is going on."

Replies are listed 'Best First'.
Re^6: Sessions Questions
by tultalk (Monk) on Mar 05, 2017 at 13:56 UTC

    Thanks for timely response. "as you see debugging by proxy can be a real pain, even more so for me when you only release code in little pieces, spread across many threads. I understand your frustration, do you understand mine?"

    I totally understand your frustration. Repeated warning say not to post lots of code. So the snippets.

    Last first:

    as to why "the warn( in my cgi scripts do not print in the error log" i cannot answer, mine do, and a google search has produced no further answers either.

    I searched everywhere also and found nothing that matched my problem. At a loss.

    On the first part, I had already tried my ($query) = @_;

    and got

    Sun Mar 5 07:51:35 2017 -: Global symbol "%query" requires explicit package name at - line 225, <DATA> line 998. Sun Mar 5 07:51:35 2017 -: BEGIN not safe after errors--compilation aborted at - line 646, <DATA> line 998.

    Shows in syntax check in Padre. This I totally don't understand as the syntax check is still finding "global symbol "%query" somewhere.

    I shut Padre down. Reopened and still there. Again did search on %query and nothing.

    Ran a debug and still there:

    Status: 500 Content-type: text/html

    Software error:

    Global symbol "%query" requires explicit package name at manageus
    ers.pm line 226, <DATA> line 998.
    BEGIN not safe after errors--compilation aborted at manageusers.pm line 647, <
    ;DATA> line 998.
    
    
    This error does not show up in komodo syntax check. 
    

      Well, what is the content of line 225/226 of manageusers.pm ?

      When you say "search on %query", how exactly did you search?


      The way forward always starts with a minimal test.

        I did search within Padre and also in file manager on the directory.

        I just uploaded the manageusers.pm file to my weberver and ran the program and got:

        Software error:

        Global symbol "%query" requires explicit package name at /home/jalamior/www/httpsdocs/cgi-bin/lib/perl/manageusers.pm line 227. Compilation failed in require at manage_users.cgi line 33. BEGIN failed--compilation aborted at manage_users.cgi line 33.

        For help, please send mail to the webmaster (webmaster@jala-mi.org), giving this error message and the time and date of the error.

        I then downloaded the manageusers.pm to make sure the upload was not messed up and searched for %query and term was not found. Very very weird.

        225 #Or, check if valid return from cgi query 226 elsif(scalar$query){ 227 if (exists $query{$sessionname}){ $sid = $query->param($sessionname); warn("ProcessLogin Request SID from Query: '$sid'"); $status = 1; } else{ $sid = undef; $status = 2;