Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1242
  • Last Modified:

new to PERL: explain a procedure

Hello : I AM totally new to PERL
I have to change some functions in a website written in PERL.
Can someone explain me step by step(line by line) what this function does ?
especially
   $Session = CGI::Session->new($SESSION_DSN, $source || $class->genRef, $SESSION_ARGS)

(I do use PHP)

Regards





sub create_session {
    my ($class, $source) = @_;
    my $Session;
   
    do {
        $Session && warn "COOKIE exist: $source !";

        $Session = CGI::Session->new($SESSION_DSN, $source || $class->genRef, $SESSION_ARGS)
            or die CGI::Session->errstr;
    }
    while (
        not($source) && not($Session->is_new)
    );

    return $Session;
}
0
yarek
Asked:
yarek
1 Solution
 
Adam314Commented:
For more details on CGI::Session, see here:
    http://search.cpan.org/~markstos/CGI-Session-4.36/lib/CGI/Session.pm

#define a subroutine, named create_session
sub create_session {
    #Get the first passed parameter as $class, the second as $source
    my ($class, $source) = @_;
    
    #define a variable $Session, with no value
    my $Session;
    
    #Beginning of a loop
    do {
        #If $Session is defined, display a warning
        $Session && warn "COOKIE exist: $source !";
 
        #Set $Session to a new CGI::Session
        #For that new object, use $SESSION_DSN as the data source
        #if $source is defined, use that for the session id, otherwise use $class->genRef
        #use $SESSION_ARGS as options
        #If creating the object failed, die (exit with error value) displaying an error message
        $Session = CGI::Session->new($SESSION_DSN, $source || $class->genRef, $SESSION_ARGS)
            or die CGI::Session->errstr;
    }
    #Continue trying that while $source is not defined, and $Session is not new
    while (
        not($source) && not($Session->is_new)
    );
    
    #Return $Session to the calling procedure
    return $Session;
}

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now