On Fri, 9 Dec 2005, Paul Lalli wrote:
> William wrote:
> > basically %USERACL is a hash containing the key and values read from the
> > following file:
> > UserID=LoginID:Group:Name:Email
assword:IsAdmin:S tatus:Servers:Lists:Logs:Macros:Eod:FileMgr:MacroL ist
nL:EditPnL:BO
> > AADUBLINJORDAN=AADUBLINJORDAN:BO:AADUBLINJORDAN:AA DUBLINJORDAN:XEV5iEfluxjWM:::::::::[]:[]:[]:
> > CHANKN=CHANKN:SYS:Kenneth Chan::XECiTZAqeyBjE:1:1 ::1:1:1:1:1:[]:[]:[]:
> >
> > now for test.pl:
> >
> > 1 #!/usr/bin/perl
> > 2
>
> Please stop putting line-numbers in your posting. It makes it
> annoyingly difficult to copy and paste your code to try to run it. If
> a certain line number is relevant, specify it with a comment.
I have removed the line numbers and added the -w switch.
# test.pl
#!/usr/bin/perl -w
use strict;
use CGI;
require "./mxrt_auth.pl";
my $query = new CGI;
my %USERACL = initAuthMgr($query); # line 10
while ( (my $key, my $value) = each %USERACL) {
print "$key = $value\n";
}
> > NOTE1: for line 10 of test.pl:
> >
> > mxrt_auth.pl::initAuthMrg is defined as follows:
> >
> > sub initAuthMgr {
> > ($AUTHQ) = @_;
> > %AUTH_INFO = $AUTHQ->cookie('MXRT_USERACL');
>
> It looks like you're not using strict in this file. Why not?
mxrt_auth.pl was written by another programmer.
I tried adding "use strict;" and -w on the shebang line, but I got the
following error/warnings:
mxrt_auth.pl: print (...) interpreted as function at ./mxrt_auth.pl line 42.
mxrt_auth.pl: Useless use of concatenation in void context at ./mxrt_auth.pl line 44.
mxrt_auth.pl: Execution of ./mxrt_auth.pl aborted due to compilation errors.
line 42, 44, and 86 are as follows:
#-------------------------------------------------------------------------------
# This function retuns the cookie for this session (hash format)
#-------------------------------------------------------------------------------
sub initAuthMgr {
($AUTHQ) = @_;
%AUTH_INFO = $AUTHQ->cookie('MXRT_USERACL'); # line 42
foreach (keys %AUTH_INFO) {
print ($AUTH_INFO{$_})."<br>"; # line 44
}
return %AUTH_INFO;
}
#-------------------------------------------------------------------------------
# Function to load the pull-down menus
#-------------------------------------------------------------------------------
sub authLog {
my ($msg, $useracl) = @_;
if ($useracl) {
%AUTH_INFO = %$useracl;
}
open (LOG, ">>my $MXRT_LOG") || return "Failed to open access log,
$!"; # line 86
flock(LOG, 2);
my $now = `date '+%m-%d-%Y %H:%M:%S'`;
chomp $now;
print LOG $now, " | ",
$AUTH_INFO{LoginID}, " | ",
$ENV{'REMOTE_HOST'}, " | ",
$ENV{'REMOTE_ADDR'}, " | ",
$ENV{'SCRIPT_NAME'} , " on ", $ENV{'HTTP_Host'} , " | ",
$msg,
"\n";
flock(LOG, 2);
close(LOG);
}
> > foreach (keys %AUTH_INFO) {
> > print ($AUTH_INFO{$_})."<br>";
>
> Is this printing out what you expect it to? I'm betting not. I'm
> betting you're not getting the <br> tags at all.
Paul, you are right. I am not getting the <br> tags at all.
In fact, I got no output when I printed %AUTH_INFO.
Related question:
How do I check if 'MXRT_USERACL' is indeed the correct cookie name? (see
line 42 of mxrt_auth.pl as above)
>
> > }
> > return %AUTH_INFO;
> > }
> >
> > Question #2) nothing is printed by line 12-14 of test.pl. (Even
> > without the line "use warnings;")
> >
> > Why???
>
> Witout knowing the exact contents of %AUTH_INFO, there is no way to be
> sure of the answer to that. What is the output of that function? Is
> it actually printing the values of %AUTH_INFO that you expect it to?
No. No output is being printed from %AUTH_INFO.