how do i create OOP perl scripts?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • happyse27
    New Member
    • Sep 2008
    • 236

    #16
    Hi Jeff,

    Thanks and Happy Holiday... This module you recommended unfortunately not in activestate perl's listed module to test the webpage timeout / after login say 10 mins no user's web activity timeout. I found this link CGI::Session::T utorial - Extended CGI::Session manual - search.cpan.org

    But got apache error log :
    [Mon Dec 29 02:41:30 2008] [error] [client 127.0.0.1] script not found or unable to stat: D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/cgi-session.pl

    and access log error :
    127.0.0.1 - - [29/Dec/2008:02:37:05 -0800] "GET /cgi-bin/cgi-session.pl HTTP/1.1" 404 220

    Code:
    #!c:/perl/bin/perl.exe
    #!/usr/local/bin/perl
    
    
    print "Content-type: text/html\n\n";
    
    # Object initialization:
        use CGI::Session;
        $session = new CGI::Session() or die CGI::Session->errstr;;
    
        $CGISESSID = $session->id();
    
        #New
        $cookie = $query->cookie( -name   => $session->name,
                                  -value  => $session->id );
        print $query->header( -cookie=>$cookie );
    
        #new 
        CGI::Session->name("SID");
        $session = new CGI::Session();
    
        # send proper HTTP header with cookies:
        print $session->header();
    
        #New
        printf ("<a href=http://127.0.0.1/cgi-bin/signin.pl">click me</a>", $session->name, 
    
    $session->id);
    
        #New
        $session = new CGI::Session( $sid );
        $session = new CGI::Session( "serializer:freezethaw", $sid );
        $session = new CGI::Session( "driver:mysql", $sid, {Handle=>$dbh} );
    
        #New
        $cgi     = new CGI::Simple();
        $session = new CGI::Session ( $cgi );
        $session = new CGI::Session( "driver:db_file;serializer:storable", $cgi);
        # etc
     
        #New
         my $name = $cgi->param('username');
        $session->param('username', $name);
    
        #New
        $session->save_param();
    
        # storing data in the session
        ##$session->param('f_name', 'Sherzod');
        # or
        ##$session->param(-name=>'l_name', -value=>'Ruzmetov');
    
        # flush the data from memory to the storage driver at least before your
        # program finishes since auto-flushing can be unreliable
        $session->flush();
    
        #New
        $name = $session->param("name");
        printf "<input type=\"text\" name=\"name\" value=\"%s\" />", $name;
    
        #New
        @fruits = @{ $session->param('fruits') };
    
        #New
        $session->load_param($cgi, ["fruits"]);
    
        #New
        print $cgi->checkbox_group(fruits=>['apple', 'banana', 'apricot']);
    
        #New
        $template = new HTML::Template(filename=>"some.tmpl", associate=>$session);
        print $template->output();
    
        #NEw
        Hello <a href="mailto:<TMPL_VAR email>"> <TMPL_VAR first_name> </a>!
    
        #New
        $session->clear(["~logged-in", "email"]);
    
        #New
        $email = $session->param("email");
    
        # retrieving data
        ##my $f_name = $session->param('f_name');
        # or
        ##my $l_name = $session->param(-name=>'l_name');
    
        # clearing a certain session parameter
        ##$session->clear(["l_name", "f_name"]);
    
        # expire '_is_logged_in' flag after 10 idle minutes:
        ##$session->expire('is_logged_in', '+10m')
    
        # expire the session itself after 1 idle hour
        $session->expire('+1h');
    
        # delete the session for good
        $session->delete();

    Comment

    • happyse27
      New Member
      • Sep 2008
      • 236

      #17
      kindly give me some pointers... cheers...

      Comment

      • numberwhun
        Recognized Expert Moderator Specialist
        • May 2007
        • 3467

        #18
        Originally posted by happyse27
        kindly give me some pointers... cheers...
        First, patience. They are a virtue. This is the holiday season and most of us probably have plans for the holiday season and answers may not come as quick as you may expect.

        Second, If Apache is complaining that it cannot find the script then you need to troubleshoot that. You are on Windows, so it isn't the same as Unix, so bear with me.

        You need to find out where the cgi-bin directory that you are supposed to put your scripts in is located. This will be in your httpd.conf file, the apache configuration file.

        That is where I would suggest you start. Windows is a funky beast to try and get LAMP working on.

        Regards,

        Jeff

        Comment

        • happyse27
          New Member
          • Sep 2008
          • 236

          #19
          Hi Sir,

          Thanks. I was not rushing anyone, I forgot to ask question although I presented the case, so I posted a second post to ask the questions for pointers. I had realized that this site needs some time to respond as some of the experts and moderators are not online sometimes... Cheers...

          Btw, what is LAMP? Cheers...


          Best Rgds,
          Andrew

          Comment

          • numberwhun
            Recognized Expert Moderator Specialist
            • May 2007
            • 3467

            #20
            Originally posted by happyse27
            Hi Sir,

            Thanks. I was not rushing anyone, I forgot to ask question although I presented the case, so I posted a second post to ask the questions for pointers. I had realized that this site needs some time to respond as some of the experts and moderators are not online sometimes... Cheers...

            Btw, what is LAMP? Cheers...


            Best Rgds,
            Andrew
            LAMP stands for Linux Apache Mysql PHP/Perl/Python. Its your basic web development environment. Its easy to get it going and running on unix, but on Windows, it tends to be a bit more of a pain. There are prebuilt installations of it for Windows that somewhat simplify it, you just have to search google for something like "lamp on windows".

            Regards,

            Jeff

            Comment

            • happyse27
              New Member
              • Sep 2008
              • 236

              #21
              Thanks! Sir... :)......

              Comment

              • happyse27
                New Member
                • Sep 2008
                • 236

                #22
                Hi All,

                1) What are the perl module that can easily interface with smtp server?

                2) And for web hosting company, do they usually provide free smtp that can send and receive unlimited emails or even sms as we would buy a domain package with them... need help as I could not find free smtp server in the web to test my perl email program...

                3) Any suggestion?? Cheers...

                4) I cant post new posting again :|

                Kindly assist on the above.


                Cheers...
                Andrew

                Comment

                • numberwhun
                  Recognized Expert Moderator Specialist
                  • May 2007
                  • 3467

                  #23
                  Andrew,

                  You really need to read your private messages (see the inbox link at the top of your page) and respond to me accordingly!

                  Regards,

                  Jeff

                  Comment

                  • happyse27
                    New Member
                    • Sep 2008
                    • 236

                    #24
                    hi sirs,

                    I did respond from my private email to forum support email saying that this website somehow due to bugs does not allow me to post new postings... that's why i added here.. But these are perl related issue for smtp and other things above which I REALLY need help. Please kindly assist.


                    Thanks in advance!
                    Andrew

                    Comment

                    • numberwhun
                      Recognized Expert Moderator Specialist
                      • May 2007
                      • 3467

                      #25
                      Originally posted by happyse27
                      hi sirs,

                      I did respond from my private email to forum support email saying that this website somehow due to bugs does not allow me to post new postings... that's why i added here.. But these are perl related issue for smtp and other things above which I REALLY need help. Please kindly assist.


                      Thanks in advance!
                      Andrew
                      I don't want to do this in the thread, but you seem to not want to read the messages I have sent to your inbox here on bytes.com (again, please click on the "inbox" link at the top of the page to see the messages I have sent you).

                      1. You need to regularly check for messages in your inbox. That is how we contact you outside of these threads. The last message I sent (a while ago), I requested that you message me back to let me know that you read and understand it. You have not done so and that is not good. There is a formal warning in there you need to read.

                      2. You keep saying that you aren't able to post new threads, yet I seem to see threads started by you on January 9th and January 17th. From what I can tell, you are definitely able to post new threads and need to abide by the rules of this site!

                      Although you say the issues are related to your issue, the questions and the way you asked them were specific to the other topics where I moved the posts and started their new threads. If it is specifically a Perl issue, fine, but when you are trying to run a Perl program and something else isn't cooperating, like Apache and you then ask an Apache specific question, that is the problem. Do you see and understand?

                      Now, please go read your messages that I have sent you and reply.

                      Regards,

                      Jeff

                      Comment

                      • KevinADC
                        Recognized Expert Specialist
                        • Jan 2007
                        • 4092

                        #26
                        Modules you can look into:

                        Net::POP3
                        Net::SMTP

                        Comment

                        • happyse27
                          New Member
                          • Sep 2008
                          • 236

                          #27
                          Hi Sirs,

                          Thanks... You can check your source codes or get more users to feedback, some days I can post, HOWEVER some days I cant(which I pasted the GUI to show you in some of my postings)... And I cant easily find the new post icon in the website(but this is not the main problem as I really cant post new post as the website did not allow me in the permission grant.)

                          And one more bug is when I logged in, it will not allow me to go forum and inform that I have login in already.

                          Hi Kevin,

                          Thanks. But does the 2 modules allow me to test to send emails to myself or other users as I understand it needs public smtp server to do the job...


                          Cheers...
                          Andrew

                          Comment

                          • happyse27
                            New Member
                            • Sep 2008
                            • 236

                            #28
                            btw, I did reply emails previously three to four different times, not sure why your email account not receive. Please check your logs...

                            I swear I did all the above, I will try to separate the topics, but please kindly be understanding towards the problems with bytes website that I am facing, if I am not allowed to post as the permission rights got problem, then what is the way or procedure to allow me to post again. Let's work on these... Cheers...
                            Last edited by happyse27; Jan 29 '09, 01:30 AM. Reason: typo

                            Comment

                            • happyse27
                              New Member
                              • Sep 2008
                              • 236

                              #29
                              btw, one more thing, your website did allow me to key in private message reply regardless of any moments, And the posting of my replies to you also didnt work. I wish I had the means to check which posting I reply...


                              Cheers...
                              Last edited by happyse27; Jan 29 '09, 01:35 AM. Reason: typo

                              Comment

                              • happyse27
                                New Member
                                • Sep 2008
                                • 236

                                #30
                                Hi Kevin,

                                I could not find net::smtp in perl package manager, but the below codes worked fine, is it the same effect? I guess I have to use gmail account to test my smtp problem as they provide free smtp server.



                                Cheers..
                                Andrew

                                Code:
                                 
                                #!c:/perl/bin/perl.exe -w  
                                  
                                   use strict;  
                                   use warnings;   
                                  
                                   use Mail::Sender::Easy qw(email);  
                                  
                                    print "Content-type: text/plain\n\n"; 
                                  
                                  
                                    email({ 
                                        'from'         => 'EMAIL REMOVED FOR YOUR PROTECTION', 
                                        'to'           => 'EMAIL REMOVED FOR YOUR PROTECTION', 
                                        'cc'           => 'IP REMOVED FOR YOUR PROTECTION', 
                                        'subject'      => 'Perl is great!', 
                                        'priority'     => 2, # 1-5 high to low 
                                        'confirm'      => 'delivery, reading', 
                                        'smtp'         =>', 
                                        'port'         => 25, 
                                        #'auth'         => 'LOGIN', 
                                        'authid'       => 'andrew', 
                                        'authpwd'      => 'PASSWORD REMOVED FOR YOUR PROTECTION', 
                                        '_text'        => 'Hello *World5* :)',     
                                        '_html'        => 'Hello <b>World</b> <img src="cid:smile1" />', 
                                        '_attachments' => { 
                                            'smiley.gif' => { 
                                                '_disptype'   => 'GIF Image', 
                                                '_inline'     => 'smile1', 
                                                'description' => 'Smiley', 
                                                'ctype'       => 'image/gif',     
                                                'file'        => 'D:/program files/Apache Software  
                                  
                                Foundation/Apache2.2/htdocs\smiley.gif', 
                                            }, 
                                            #'mydata.pdf' => { 
                                                #'description' => 'Data Sheet',   
                                                #'ctype'       => 'application/pdf', 
                                                #'msg'         => $pdf_guts, 
                                            #}, 
                                        }, 
                                    }) or die "email() failed: $@";
                                Last edited by numberwhun; Jan 29 '09, 03:16 AM. Reason: Remove Email, Password, IP for user protection

                                Comment

                                Working...