FreshmenProgrammer
Programmer
I was having trouble with understanding some code this is just a specific question but i have all the pieces of code from sparate files.
this is from a file called M responder.cgi.
my $auth_program = {
student => {
test => '/usr/local/oracle/oraappl/apps/scripts/mcds0020t.pm',
prod => '/usr/local/oracle/oraappl/apps/scripts/mcds0020.pm',
},
## Determine mode ('test' or 'prod')
my $mode = $q->url_param('mode');
$mode = 'prod' unless ($mode =~ /test/i);
## Determine student, employee or admin
my $user_type = $q->param('user_type');
$user_type = 'student' unless (($user_type =~ /employee/i) || ($user_type =~ /ad/i));
my $r = new M::Request();
$r->setAuthenticationProgram($auth_program->{$user_type}->{$mode});
the following code is from a file called M::Request();
sub setAuthenticationProgram
{
my $thing = 'authentication_script';
my $self = shift;
my $value = shift;
$self->{$thing} = $value;
return $value;
}
Do u see the line $r->setAuthenicationProgram($auth_program->{$user_type}->{$mode}); i don't really understand what its doing. Is it sending the user type and mode to the sub so that $self will equal student and $value will equal prod. I dont really understand whats happening here. Can you help me out with explaining this to me. thank you. I know its a reference to a hash but need some clarification on this code.. Thank you! This is my first day in the professional world after finishing school so whatever any one can answer would be greatly appreciated. Thank you!!
this is from a file called M responder.cgi.
my $auth_program = {
student => {
test => '/usr/local/oracle/oraappl/apps/scripts/mcds0020t.pm',
prod => '/usr/local/oracle/oraappl/apps/scripts/mcds0020.pm',
},
## Determine mode ('test' or 'prod')
my $mode = $q->url_param('mode');
$mode = 'prod' unless ($mode =~ /test/i);
## Determine student, employee or admin
my $user_type = $q->param('user_type');
$user_type = 'student' unless (($user_type =~ /employee/i) || ($user_type =~ /ad/i));
my $r = new M::Request();
$r->setAuthenticationProgram($auth_program->{$user_type}->{$mode});
the following code is from a file called M::Request();
sub setAuthenticationProgram
{
my $thing = 'authentication_script';
my $self = shift;
my $value = shift;
$self->{$thing} = $value;
return $value;
}
Do u see the line $r->setAuthenicationProgram($auth_program->{$user_type}->{$mode}); i don't really understand what its doing. Is it sending the user type and mode to the sub so that $self will equal student and $value will equal prod. I dont really understand whats happening here. Can you help me out with explaining this to me. thank you. I know its a reference to a hash but need some clarification on this code.. Thank you! This is my first day in the professional world after finishing school so whatever any one can answer would be greatly appreciated. Thank you!!