Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Time question

Expand Messages
  • Tom Barron
    ... use POSIX; $sec = POSIX::mktime(0,4,11,26,6,100); # July 26, 2000 11:04 a.m. print sec = $sec n ; print join( , localtime($sec)), n ; Note that July
    Message 1 of 14 , Sep 1, 2000
    • 0 Attachment
      bob jacobson wrote:
      > Can anyone tell me of a way to determine the time value or # of seconds of
      > anydate? For example, how can I find the seconds for July 26, 2000 at 11:04
      > am. Having this value will allow me to use the localtime function to get
      > needed info such as the day of the week for this date. Or maybe is there
      > another way of doing this as opposed to using localtime? TIA!

      use POSIX;

      $sec = POSIX::mktime(0,4,11,26,6,100); # July 26, 2000 11:04 a.m.
      print "sec = $sec\n";
      print join(" ", localtime($sec)), "\n";

      Note that July is 6 (jan = 0, feb = 1, etc.) and 2000 is 100 (1999 = 99,
      2001 = 101, etc.).

      Also beware of daylight savings time adjustments. When I run the code
      above on my machine, I get:

      DB<4> $sec = POSIX::mktime(0,4,11,26,6,100); # July 26, 2000 11:04
      a.m.

      DB<5> print "sec = $sec\n";
      sec = 964631040

      DB<6> print join(" ", localtime($sec)), "\n";
      0 4 12 26 6 100 3 207 1
      ^^
      DST adjusted hour

      hth...
      Tom
    • bob jacobson
      Thank you very much, this is exactly what I needed! ... From: Tom Barron [mailto:tbarron@mindspring.com] Sent: Friday, September 01, 2000 4:58 PM To:
      Message 2 of 14 , Sep 1, 2000
      • 0 Attachment
        Thank you very much, this is exactly what I needed!


        -----Original Message-----
        From: Tom Barron [mailto:tbarron@...]
        Sent: Friday, September 01, 2000 4:58 PM
        To: perl-beginner@egroups.com
        Subject: Re: [PBML] Time question



        bob jacobson wrote:
        > Can anyone tell me of a way to determine the time value or # of seconds of
        > anydate? For example, how can I find the seconds for July 26, 2000 at
        11:04
        > am. Having this value will allow me to use the localtime function to get
        > needed info such as the day of the week for this date. Or maybe is there
        > another way of doing this as opposed to using localtime? TIA!

        use POSIX;

        $sec = POSIX::mktime(0,4,11,26,6,100); # July 26, 2000 11:04 a.m.
        print "sec = $sec\n";
        print join(" ", localtime($sec)), "\n";

        Note that July is 6 (jan = 0, feb = 1, etc.) and 2000 is 100 (1999 = 99,
        2001 = 101, etc.).

        Also beware of daylight savings time adjustments. When I run the code
        above on my machine, I get:

        DB<4> $sec = POSIX::mktime(0,4,11,26,6,100); # July 26, 2000 11:04
        a.m.

        DB<5> print "sec = $sec\n";
        sec = 964631040

        DB<6> print join(" ", localtime($sec)), "\n";
        0 4 12 26 6 100 3 207 1
        ^^
        DST adjusted hour

        hth...
        Tom
      • Octavian Rasnita
        What do you want to do exactly? Do you want to time how long a script runs? You could use my $time = $times[0]; Teddy s Center: http://teddy.fcc.ro/ Mail:
        Message 3 of 14 , Aug 18, 2002
        • 0 Attachment
          What do you want to do exactly?
          Do you want to time how long a script runs?

          You could use
          my $time = $times[0];

          Teddy's Center: http://teddy.fcc.ro/
          Mail: orasnita@...

          ----- Original Message -----
          From: "willbmoss" <wmoss@...>
          To: <perl-beginner@yahoogroups.com>
          Sent: Monday, August 19, 2002 4:59 AM
          Subject: [PBML] Time question


          > I am trying to time how long something takes, but i want it to be
          > more accurate that just seconds (i.e. milliseconds) i know about the
          > time function and localtime and all that, but those only return
          > whole second values... any ideas?
          >
          > Thanks,
          > Will
          >
          >
          >
          > Unsubscribing info is here:
          http://help.yahoo.com/help/us/groups/groups-32.html
          >
          > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
          >
          >
          >
        • ramon@ramonred.net
          Hi, I am using the following reg ex to test for a blank line: if (/^ s*$/) { do something...... } I am getting a susititution pattern not terminated error. I
          Message 4 of 14 , Aug 19, 2002
          • 0 Attachment
            Hi,

            I am using the following reg ex to test for a blank line:
            if (/^\s*$/) {

            do something......

            }


            I am getting a susititution pattern not terminated error. I have this reg ex
            else where in the program and it isn't giving this error.

            Any help or ideas would be appreciated. Thanks. :)

            Ramon



            [Non-text portions of this message have been removed]
          • Charles K. Clarkson
            ... Then something else is the error. Show us more code. Are you sure you know what is in $_? HTH, Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy
            Message 5 of 14 , Aug 19, 2002
            • 0 Attachment
              ramon@... [mailto:ramon@...] wrote:

              : I am using the following reg ex to test for
              : a blank line:
              :
              : if (/^\s*$/) {
              :
              : do something......
              :
              : }
              :
              : I am getting a susititution pattern not
              : terminated error. I have this reg ex else
              : where in the program and it isn't giving
              : this error.

              Then something else is the error. Show us
              more code. Are you sure you know what is in
              $_?


              HTH,

              Charles K. Clarkson
              --
              Head Bottle Washer,
              Clarkson Energy Homes, Inc.
              Small commercial and residential rehabilitation specialists.
              254 968-8328

              CJ Web Work - Solutions for Real Estate Investors.
              972 216-4952
            • ramon@ramonred.net
              It turned out to be substitution error, just not where the error message reported it. It was another if (reg-ex) combo further up the stream. Thanks very much
              Message 6 of 14 , Aug 19, 2002
              • 0 Attachment
                It turned out to be substitution error, just not where the error message
                reported it. It was another if (reg-ex) combo further up
                the stream. Thanks very much though. :)
                -----Original Message-----
                From: Charles K. Clarkson [mailto:cclarkson@...]
                Sent: Monday, August 19, 2002 12:57 AM
                To: perl-beginner@yahoogroups.com
                Subject: RE: [PBML] substution pattern not terminated


                ramon@... [mailto:ramon@...] wrote:

                : I am using the following reg ex to test for
                : a blank line:
                :
                : if (/^\s*$/) {
                :
                : do something......
                :
                : }
                :
                : I am getting a susititution pattern not
                : terminated error. I have this reg ex else
                : where in the program and it isn't giving
                : this error.

                Then something else is the error. Show us
                more code. Are you sure you know what is in
                $_?


                HTH,

                Charles K. Clarkson
                --
                Head Bottle Washer,
                Clarkson Energy Homes, Inc.
                Small commercial and residential rehabilitation specialists.
                254 968-8328

                CJ Web Work - Solutions for Real Estate Investors.
                972 216-4952



                Yahoo! Groups Sponsor
                ADVERTISEMENT



                Unsubscribing info is here:
                http://help.yahoo.com/help/us/groups/groups-32.html

                Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



                [Non-text portions of this message have been removed]
              • willbmoss
                i want to know how long in seconds and fractions of a second a peice of my code takes to execute. Will ... the ... http://docs.yahoo.com/info/terms/
                Message 7 of 14 , Aug 20, 2002
                • 0 Attachment
                  i want to know how long in seconds and fractions of a second a peice
                  of my code takes to execute.

                  Will

                  --- In perl-beginner@y..., "Octavian Rasnita" <orasnita@h...> wrote:
                  > What do you want to do exactly?
                  > Do you want to time how long a script runs?
                  >
                  > You could use
                  > my $time = $times[0];
                  >
                  > Teddy's Center: http://teddy.fcc.ro/
                  > Mail: orasnita@h...
                  >
                  > ----- Original Message -----
                  > From: "willbmoss" <wmoss@s...>
                  > To: <perl-beginner@y...>
                  > Sent: Monday, August 19, 2002 4:59 AM
                  > Subject: [PBML] Time question
                  >
                  >
                  > > I am trying to time how long something takes, but i want it to be
                  > > more accurate that just seconds (i.e. milliseconds) i know about
                  the
                  > > time function and localtime and all that, but those only return
                  > > whole second values... any ideas?
                  > >
                  > > Thanks,
                  > > Will
                  > >
                  > >
                  > >
                  > > Unsubscribing info is here:
                  > http://help.yahoo.com/help/us/groups/groups-32.html
                  > >
                  > > Your use of Yahoo! Groups is subject to
                  http://docs.yahoo.com/info/terms/
                  > >
                  > >
                  > >
                • Nathan.Jeffrey@dhs.vic.gov.au
                  In Unix, try time , and read the manpage for time . N willbmoss 21/08/2002 04:29 PM Please respond to perl-beginner To:
                  Message 8 of 14 , Aug 20, 2002
                  • 0 Attachment
                    In Unix, try "time <scriptname>", and read the manpage for "time".

                    N





                    "willbmoss" <wmoss@...>
                    21/08/2002 04:29 PM
                    Please respond to perl-beginner


                    To: perl-beginner@yahoogroups.com
                    cc:
                    Subject: Re: [PBML] Time question


                    i want to know how long in seconds and fractions of a second a peice
                    of my code takes to execute.

                    Will

                    --- In perl-beginner@y..., "Octavian Rasnita" <orasnita@h...> wrote:
                    > What do you want to do exactly?
                    > Do you want to time how long a script runs?
                    >
                    > You could use
                    > my $time = $times[0];
                    >
                    > Teddy's Center: http://teddy.fcc.ro/
                    > Mail: orasnita@h...
                    >
                    > ----- Original Message -----
                    > From: "willbmoss" <wmoss@s...>
                    > To: <perl-beginner@y...>
                    > Sent: Monday, August 19, 2002 4:59 AM
                    > Subject: [PBML] Time question
                    >
                    >
                    > > I am trying to time how long something takes, but i want it to be
                    > > more accurate that just seconds (i.e. milliseconds) i know about
                    the
                    > > time function and localtime and all that, but those only return
                    > > whole second values... any ideas?
                    > >
                    > > Thanks,
                    > > Will
                    > >
                    > >
                    > >
                    > > Unsubscribing info is here:
                    > http://help.yahoo.com/help/us/groups/groups-32.html
                    > >
                    > > Your use of Yahoo! Groups is subject to
                    http://docs.yahoo.com/info/terms/
                    > >
                    > >
                    > >



                    Unsubscribing info is here:
                    http://help.yahoo.com/help/us/groups/groups-32.html

                    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/







                    _________________________________________________________________________________

                    This email contains confidential information intended only for the person named above and may be subject to legal privilege. If you are not the intended recipient, any disclosure, copying or use of this information is prohibited. The Department provides no guarantee that this communication is free of virus or that it has not been intercepted or interfered with. If you have received this email in error or have any other concerns regarding its transmission, please notify Postmaster@...
                    _________________________________________________________________________________
                  • Nathan.Jeffrey@dhs.vic.gov.au
                    Or, there s the perl Benchmark library :-) N willbmoss 21/08/2002 04:29 PM Please respond to perl-beginner To:
                    Message 9 of 14 , Aug 20, 2002
                    • 0 Attachment
                      Or, there's the perl Benchmark library :-)

                      N





                      "willbmoss" <wmoss@...>
                      21/08/2002 04:29 PM
                      Please respond to perl-beginner


                      To: perl-beginner@yahoogroups.com
                      cc:
                      Subject: Re: [PBML] Time question


                      i want to know how long in seconds and fractions of a second a peice
                      of my code takes to execute.

                      Will

                      --- In perl-beginner@y..., "Octavian Rasnita" <orasnita@h...> wrote:
                      > What do you want to do exactly?
                      > Do you want to time how long a script runs?
                      >
                      > You could use
                      > my $time = $times[0];
                      >
                      > Teddy's Center: http://teddy.fcc.ro/
                      > Mail: orasnita@h...
                      >
                      > ----- Original Message -----
                      > From: "willbmoss" <wmoss@s...>
                      > To: <perl-beginner@y...>
                      > Sent: Monday, August 19, 2002 4:59 AM
                      > Subject: [PBML] Time question
                      >
                      >
                      > > I am trying to time how long something takes, but i want it to be
                      > > more accurate that just seconds (i.e. milliseconds) i know about
                      the
                      > > time function and localtime and all that, but those only return
                      > > whole second values... any ideas?
                      > >
                      > > Thanks,
                      > > Will
                      > >
                      > >
                      > >
                      > > Unsubscribing info is here:
                      > http://help.yahoo.com/help/us/groups/groups-32.html
                      > >
                      > > Your use of Yahoo! Groups is subject to
                      http://docs.yahoo.com/info/terms/
                      > >
                      > >
                      > >



                      Unsubscribing info is here:
                      http://help.yahoo.com/help/us/groups/groups-32.html

                      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/







                      _________________________________________________________________________________

                      This email contains confidential information intended only for the person named above and may be subject to legal privilege. If you are not the intended recipient, any disclosure, copying or use of this information is prohibited. The Department provides no guarantee that this communication is free of virus or that it has not been intercepted or interfered with. If you have received this email in error or have any other concerns regarding its transmission, please notify Postmaster@...
                      _________________________________________________________________________________
                    • Octavian Rasnita
                      If you want a quick solution, use the times function. Put the following code at the end of your script: my $end = times[0]; print $end seconds n ; Here is a
                      Message 10 of 14 , Aug 21, 2002
                      • 0 Attachment
                        If you want a quick solution, use the times function.

                        Put the following code at the end of your script:

                        my $end = times[0];
                        print "$end seconds\n";

                        Here is a message I've received:

                        The times function returns the amount of job time consumed by this program
                        and any child processes
                        of this program.

                        The syntax for the times function is

                        @timelist = times

                        As you can see, times accepts no arguments. It returns a list consisting of
                        the following four
                        floating-point numbers:
                        - The user time consumed by this program
                        - The system time consumed by this program
                        - The user time consumed by the child processes, if they exist
                        - The system time consumed by the child processes, if they exist
                        -------------------------------------------------------
                        So there you have it. When you are calling $begin = (times)[0]; You
                        are calling times function
                        and specifying that you only want to get back the first element of the
                        returned array, which happens
                        to be the "user time consumed".

                        If you want more details, you might use the Benchmark module.

                        Teddy's Center: http://teddy.fcc.ro/
                        Mail: orasnita@...

                        ----- Original Message -----
                        From: "willbmoss" <wmoss@...>
                        To: <perl-beginner@yahoogroups.com>
                        Sent: Wednesday, August 21, 2002 9:29 AM
                        Subject: Re: [PBML] Time question


                        > i want to know how long in seconds and fractions of a second a peice
                        > of my code takes to execute.
                        >
                        > Will
                        >
                        > --- In perl-beginner@y..., "Octavian Rasnita" <orasnita@h...> wrote:
                        > > What do you want to do exactly?
                        > > Do you want to time how long a script runs?
                        > >
                        > > You could use
                        > > my $time = $times[0];
                        > >
                        > > Teddy's Center: http://teddy.fcc.ro/
                        > > Mail: orasnita@h...
                        > >
                        > > ----- Original Message -----
                        > > From: "willbmoss" <wmoss@s...>
                        > > To: <perl-beginner@y...>
                        > > Sent: Monday, August 19, 2002 4:59 AM
                        > > Subject: [PBML] Time question
                        > >
                        > >
                        > > > I am trying to time how long something takes, but i want it to be
                        > > > more accurate that just seconds (i.e. milliseconds) i know about
                        > the
                        > > > time function and localtime and all that, but those only return
                        > > > whole second values... any ideas?
                        > > >
                        > > > Thanks,
                        > > > Will
                        > > >
                        > > >
                        > > >
                        > > > Unsubscribing info is here:
                        > > http://help.yahoo.com/help/us/groups/groups-32.html
                        > > >
                        > > > Your use of Yahoo! Groups is subject to
                        > http://docs.yahoo.com/info/terms/
                        > > >
                        > > >
                        > > >
                        >
                        >
                        >
                        > Unsubscribing info is here:
                        http://help.yahoo.com/help/us/groups/groups-32.html
                        >
                        > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
                        >
                        >
                        >
                      • Prakash Kumar
                        Hello friends.. is there any module.. which i can use to find.. nslookup... to find hostname.. i dont want to use `` to find that.. Thanks.. Prak
                        Message 11 of 14 , Aug 22, 2002
                        • 0 Attachment
                          Hello friends..

                          is there any module.. which i can use to find.. nslookup... to find
                          hostname.. i dont want to use `` to find that..

                          Thanks..
                          Prak
                        • Priss
                          Seen some scripts using Net::DNS... Priss ... Hello friends.. ... __________________________________________________ Do You Yahoo!? Everything you ll ever need
                          Message 12 of 14 , Aug 22, 2002
                          • 0 Attachment
                            Seen some scripts using Net::DNS...

                            Priss

                            --- Prakash Kumar <prakash@...> wrote: >
                            Hello friends..
                            >
                            > is there any module.. which i can use to find..
                            > nslookup... to find
                            > hostname.. i dont want to use `` to find that..
                            >
                            > Thanks..
                            > Prak
                            >
                            >
                            >
                            > ------------------------ Yahoo! Groups Sponsor
                            >
                            > Unsubscribing info is here:
                            > http://help.yahoo.com/help/us/groups/groups-32.html
                            >
                            > Your use of Yahoo! Groups is subject to
                            > http://docs.yahoo.com/info/terms/
                            >
                            >

                            __________________________________________________
                            Do You Yahoo!?
                            Everything you'll ever need on one web page
                            from News and Sport to Email and Music Charts
                            http://uk.my.yahoo.com
                          • Prakash Kumar
                            hello friend.. how to create .pod file for some module which i created ... is there any tool for that ?? thank u... -prak
                            Message 13 of 14 , Aug 22, 2002
                            • 0 Attachment
                              hello friend.. how to create .pod file for some module which i created ...
                              is there any tool for that ??

                              thank u...
                              -prak
                            • Nathan.Jeffrey@dhs.vic.gov.au
                              That s exactly the way I did it :-) ... use Net::DNS; sub rev_dns_check { my($host, $ip) = @_ if scalar(@_) == 2; my(@servers) = qw( ns1.lan ns2.lan );
                              Message 14 of 14 , Aug 22, 2002
                              • 0 Attachment
                                That's exactly the way I did it :-)

                                -----

                                use Net::DNS;

                                sub rev_dns_check {
                                my($host, $ip) = @_ if scalar(@_) == 2;
                                my(@servers) = qw( ns1.lan ns2.lan );
                                my($resolver, $packet, $rr);
                                my(%name);
                                my $outfile = 'dns_errs.out';

                                return 0 unless defined $host;
                                # return 0 unless gethostbyname($host);

                                $resolver = Net::DNS::Resolver->new();

                                foreach (@servers) {

                                $resolver->nameservers($_);
                                #$resolver->print;

                                $packet = $resolver->query($ip);
                                #$packet->print;

                                if ($packet) {
                                foreach $rr ($packet->answer) {
                                $name{$_} = $rr->ptrdname if $rr->type eq
                                'PTR';
                                # $rr->print;
                                # print Data::Dumper->Dump([\$rr],
                                ['rr']),"\n";
                                }
                                }
                                }
                                # print Data::Dumper->Dump([\%name], ["name"]),"\n" ;

                                open OUTFILE, ">> $outfile" or warn "Can't open $outfile! : $!";

                                grep { print OUTFILE "$host ($ip) has errors, reverse lookup DNS
                                data dump...\n" and
                                print OUTFILE Data::Dumper->Dump([\%name],
                                ["name"]),"\n" and
                                close OUTFILE and
                                return 0 unless m/^$host/ } values(%name);
                                close OUTFILE and return 1;

                                }

                                sub fwd_dns_check {
                                my($host, $ip) = @_ if scalar(@_) == 2;
                                my(@servers) = qw( ns1.lan ns2.lan );
                                my($resolver, $packet, $rr);
                                my(%inverse, %ip);
                                my $outfile = 'dns_errs.out';

                                return 0 unless defined $host;
                                return 0 unless gethostbyname($host);

                                $resolver = Net::DNS::Resolver->new();

                                foreach (@servers) {

                                $resolver->nameservers($_);
                                #$resolver->print;

                                $packet = $resolver->query($host);
                                #$packet->print;

                                if ($packet) {
                                foreach $rr ($packet->answer) {
                                $ip{$_} = $rr->address;
                                }
                                }

                                }

                                %inverse = reverse %ip;

                                open OUTFILE, ">> $outfile" or warn "Can't open $outfile! : $!";

                                if ( ( scalar(@servers) != scalar(keys(%ip)) ) or
                                ( scalar(keys(%inverse)) > 1 ) or
                                ( (keys(%inverse))[0] ne $ip) ) {
                                print OUTFILE "$host ($ip) has errors, forward lookup DNS
                                data dump...\n";
                                print OUTFILE Data::Dumper->Dump([\%ip], ["ip"]), "\n";
                                close OUTFILE;
                                return 0;
                                } else {
                                close OUTFILE;
                                return 1;
                                }

                                }






                                Priss <priss_uk_2000@...>
                                23/08/2002 04:50 AM
                                Please respond to perl-beginner


                                To: perl-beginner@yahoogroups.com
                                cc:
                                Subject: RE: [PBML] nslookup in perl.. ??


                                Seen some scripts using Net::DNS...

                                Priss

                                --- Prakash Kumar <prakash@...> wrote: >
                                Hello friends..
                                >
                                > is there any module.. which i can use to find..
                                > nslookup... to find
                                > hostname.. i dont want to use `` to find that..
                                >
                                > Thanks..
                                > Prak
                                >
                                >
                                >
                                > ------------------------ Yahoo! Groups Sponsor
                                >
                                > Unsubscribing info is here:
                                > http://help.yahoo.com/help/us/groups/groups-32.html
                                >
                                > Your use of Yahoo! Groups is subject to
                                > http://docs.yahoo.com/info/terms/
                                >
                                >

                                __________________________________________________
                                Do You Yahoo!?
                                Everything you'll ever need on one web page
                                from News and Sport to Email and Music Charts
                                http://uk.my.yahoo.com


                                Unsubscribing info is here:
                                http://help.yahoo.com/help/us/groups/groups-32.html

                                Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/







                                _________________________________________________________________________________

                                This email contains confidential information intended only for the person named above and may be subject to legal privilege. If you are not the intended recipient, any disclosure, copying or use of this information is prohibited. The Department provides no guarantee that this communication is free of virus or that it has not been intercepted or interfered with. If you have received this email in error or have any other concerns regarding its transmission, please notify Postmaster@...
                                _________________________________________________________________________________
                              Your message has been successfully submitted and would be delivered to recipients shortly.