Re: use Time::Piece

2018-11-01 Thread Martin McCormick
Jim Gibson writes: > On Oct 31, 2018, at 1:29 PM, Martin McCormick > wrote: > > my $t1 = Time::Piece->strptime("$obtime[1], %d %b %Y %H:%M:%S %z”); > > strptime is a method with two arguments: string to be parsed, format to > be used for parsing. You have

Re: use Time::Piece

2018-11-01 Thread Martin McCormick
Sam writes: > > > > None of your arguments are right. For one, you are using the '%D' flag > which is the same as saying '%m/%d/%y' > > > This works fine from a quick command line test: > > perl -e 'use Time::Piece; $t = "30 Oct

Re: use Time::Piece

2018-10-31 Thread Sam
On 10/30/2018 10:24 PM, Martin McCormick wrote: I can not seem to send Time::Piece any syntax it likes. The file I am reading sends a time stamp that should conform to RFC822 date stamps. An example of a stamp follows: main::(lwx:204):my @obtime = split

Re: use Time::Piece

2018-10-31 Thread Jim Gibson
On Oct 31, 2018, at 1:29 PM, Martin McCormick wrote: > > > I'd like to say that it's working but not yet. There seems to be > nothing wrong with the string now. > > my $t1 = Time::Piece->strptime("$obtime[1], %d %b %Y %H:%M:%S %z”); strptime is a meth

Re: use Time::Piece

2018-10-31 Thread Martin McCormick
monitions in the book says "Never trust data." That leading space came from the split of a , separated string and it completely got by me. I'd like to say that it's working but not yet. There seems to be nothing wrong with the string now. my $t1 = Time::Piece->strptime

Re: use Time::Piece

2018-10-30 Thread Uri Guttman
On 10/30/18 11:24 PM, Martin McCormick wrote: I can not seem to send Time::Piece any syntax it likes. The file I am reading sends a time stamp that should conform to RFC822 date stamps. An example of a stamp follows: main::(lwx:204):my @obtime = split( /\,+/, $data

use Time::Piece

2018-10-30 Thread Martin McCormick
I can not seem to send Time::Piece any syntax it likes. The file I am reading sends a time stamp that should conform to RFC822 date stamps. An example of a stamp follows: main::(lwx:204):my @obtime = split( /\,+/, $data->{observation_time_ rfc822} ); DB<2&

Re: What is time, anyway?

2018-01-29 Thread SurfShop
> On Jan 29, 2018, at 12:18 PM, Octavian Rasnita wrote: > > from: perldoc -f time > > timeReturns the number of non-leap seconds since whatever time the > system considers to be the epoch, suitable for feeding to > "gmtime" and "loca

Re: What is time, anyway?

2018-01-29 Thread Andy Bach
YOu might look at localtime() perldoc.perl.org/functions/localtime.html or gmtime perldoc.perl.org/functions/gmtime.html time() returns the epoch time - seconds since Jan 1, 1970 UTC (IIRC), localtime transforms it to just that. So all your time() stamps will be the same and localtime() can

Re: What is time, anyway?

2018-01-29 Thread Octavian Rasnita
from: perldoc -f time timeReturns the number of non-leap seconds since whatever time the system considers to be the epoch, suitable for feeding to "gmtime" and "localtime". On most systems the epoch is 00:00:00 UTC, January 1, 1970; a

What is time, anyway?

2018-01-29 Thread SurfShop
Basic time question here. Looking at sites such as http://perldoc.perl.org/functions/time.html, I'm not seeing what the time() function is based on. Does it return the time of the server, or UTC? Is it affected by any timezone setting on the server or in a script? I t

Re: Time::HiRes output

2017-05-27 Thread SSC_perl
wrote is coming in handy, as well. It’s very simple - it only lists the subs in the order that they are called, the time they take, and a few key variables to see how/why they are being called. This shows me the sequence of events depending on which links were clicked, which is giving me

Re: Time::HiRes output

2017-05-24 Thread lee
> > https://www.perl.org/about/whitepapers/perl-profiling.html > > On Wed, May 24, 2017, 22:12 SSC_perl wrote: > >> I’m timing sub routines to get an idea of where my scripts spend >> the most of their time. This is an example of what I’m doing: >

Re: Time::HiRes output

2017-05-24 Thread Chas. Owens
-profiling.html On Wed, May 24, 2017, 22:12 SSC_perl wrote: > I’m timing sub routines to get an idea of where my scripts spend > the most of their time. This is an example of what I’m doing: > > use Time::HiRes qw( clock ); > my $clock0 = clock(); > ... # Do something. > my $c

Time::HiRes output

2017-05-24 Thread SSC_perl
I’m timing sub routines to get an idea of where my scripts spend the most of their time. This is an example of what I’m doing: use Time::HiRes qw( clock ); my $clock0 = clock(); ... # Do something. my $clock1 = clock(); my $clockd = $clock1 - $clock0; I’m getting values like

Re: Wanted: Help performing Date-Time Arithmetic using emacs/vi and perl

2016-04-19 Thread Shlomi Fish
nd then execute the above VI/Ex command you get: > 4*atan(1))=3.14159265358979 > > > Here is my failed attempt to do date arithmetic: > (use Date::Calc ( ":all" ); use Date::Manip; my ( $date, $yy, $dd, $mm ); > $date = scalar localtime( ( time() - ( 24 * 60 * 60 ) )

Wanted: Help performing Date-Time Arithmetic using emacs/vi and perl

2016-04-18 Thread Richard Heintze via beginners
: (use Date::Calc ( ":all" ); use Date::Manip; my ( $date, $yy, $dd, $mm ); $date = scalar localtime( ( time() - ( 24 * 60 * 60 ) ) ); $date)="" Can someone help me figure out how to use the eval function in my perl one-liner to evaluate date time arithmetic? Thanks,Siegfried

Re: Debugging and passing constant value at run time

2015-07-07 Thread Sharanbasappa Raghapur, ERS, HCLTech
LTech" wrote: > I am using constant mainly to enable printing of debugging messages > (e.g. use constant DEBUGGING_L1 => 0;) Normally, the value is '0' and > when I need to see debug messages, I make this 1 and run the script. > > Is there a way to allocate value to

Re: Debugging and passing constant value at run time

2015-07-07 Thread Charles DeRykus
I make this 1 and run the script. > > Is there a way to allocate value to constants at run time so that I > can avoid editing the script again and again? Also, is there a better > way to handle debugging? You don't get those conditional compilation speedup's but you could pass

Re: Debugging and passing constant value at run time

2015-07-07 Thread Uri Guttman
a significant difference when being compiled. and also not testing that DEBUG boolean at run time can add up to if it those sections get called a lot. that is why these tricks were created to eliminate debugging code at compile time. it all depends on the size of the program, amount of

Re: Debugging and passing constant value at run time

2015-07-07 Thread Ron Bergin
g Cc: "Ron Bergin" Sent: Tuesday, July 7, 2015 7:41:34 AM Subject: Re: Debugging and passing constant value at run time On Tue, 7 Jul 2015 07:27:49 -0700 (PDT) Ron Bergin wrote: > Using a DEBUG constant and assigning its value via an environment > variable are both common, but has a

Re: Debugging and passing constant value at run time

2015-07-07 Thread Shawn H Corey
On Tue, 7 Jul 2015 07:27:49 -0700 (PDT) Ron Bergin wrote: > Using a DEBUG constant and assigning its value via an environment > variable are both common, but has a drawback and would not be my > choice of approach. I prefer to use a lexical var (with file scope) > and assign it via command line o

Re: Debugging and passing constant value at run time

2015-07-07 Thread Ron Bergin
> \$VERBOSE ); if( $DEBUG ){ say 'hello'; say 'goodbye' if $VERBOSE > 1; } Ron From: "Sharanbasappa Raghapur, ERS, HCLTech" To: "Perl Beginners" Sent: Tuesday, July 7, 2015 4:40:35 AM Subject: Debugging and passing constant value at run t

Re: Debugging and passing constant value at run time

2015-07-07 Thread Shawn H Corey
I make this 1 and run the script. > > Is there a way to allocate value to constants at run time so that I > can avoid editing the script again and again? Also, is there a better > way to handle debugging? Yup, see http://lookatperl.blogspot.ca/2013/07/a-look-at-conditional-compiling

Debugging and passing constant value at run time

2015-07-07 Thread Sharanbasappa Raghapur, ERS, HCLTech
Hi, I am using constant mainly to enable printing of debugging messages (e.g. use constant DEBUGGING_L1 => 0;) Normally, the value is '0' and when I need to see debug messages, I make this 1 and run the script. Is there a way to allocate value to constants at run time so tha

CPAN install problems - WWW::Mechanize::Firefox fails allmost every time

2015-02-19 Thread Martin Kaspar
hi Gary, hi List, today i am running opensuse 13.1 - and i am trying to install mozrepl and perl BTW - friends told me to avoid all perlbrew tings... so i did the following perl -MCPAN -e shell cpan> install WWW::Mechanize::Firefox - it failed... see Parse errors: No plan found in TAP ou

Re: time based test

2014-02-20 Thread shawn wilson
Thanks Also, for completeness, in that doc is also stated Time::Warp and someone also pointed me to Time::Mock and Test::TimeMock. The later seems to have the best interface for my needs, so I'll go with that. On Sat, Feb 15, 2014 at 6:05 AM, David Precious wrote: > On Fri, 14 Feb 2014

Re: time based test

2014-02-15 Thread David Precious
On Fri, 14 Feb 2014 16:21:52 -0500 shawn wilson wrote: > What I want is to be able to make a program /think/ that it's like a > week in the future without messing with the system time at all. So > something that overrides gmtime and localtime and the like with some > starti

Re: time based test

2014-02-14 Thread shawn wilson
hich part of the program do > you want to fool? You mean, you want > print scalar localtime(), "\n"; > > to print > Fri Feb 21 16:21:11 2014 > Yes, and works the same with Date::Time etc. So basically, I have a long running process and it flushes and reports on

time based test

2014-02-14 Thread shawn wilson
What I want is to be able to make a program /think/ that it's like a week in the future without messing with the system time at all. So something that overrides gmtime and localtime and the like with some starting point would be awesome. Anything like that? -- To unsubscribe, e-mail: begi

Re: Current time with DST

2013-04-18 Thread Dr.Ruud
time q{%F %T %z}, localtime; ' 2013-04-18 20:36:16 +0200 With DateTime, you can for example do: perl -Mstrict -MDateTime -wle ' print DateTime -> now(time_zone => "Europe/Amsterdam") -> strftime(q{%F %T %z}); ' 2013-04-19 08:23:30 +0200 Also check out Time::

Re: Current time with DST

2013-04-18 Thread Uri Guttman
On 04/18/2013 03:13 AM, Dr.Ruud wrote: If your box already is in that timezone, you can use localtime(). perl -Mstrict -we' my @dt = reverse +(localtime)[0..5]; $dt[0] += 1900; # year $dt[1] += 1; # month printf qq{%s-%02d-%02d %02d:%02d:%02d\n}, @dt; ' 2013-04-18 09:09:22 i wo

Re: Current time with DST

2013-04-18 Thread Brandon McCaig
On Thu, Apr 18, 2013 at 07:26:13AM -0300, Brian Fraser wrote: > On Wed, Apr 17, 2013 at 10:24 PM, Brandon McCaig wrote: > > Using the warnings pragma is good! You should also use the strict > > pragma: > > > > use strict; > > > > > This is not needed. Since 5.14, 'use VERSION' automatically enable

Re: Current time with DST

2013-04-18 Thread Ricardo Pais Oliveira
On Thu, Apr 18, 2013 at 2:24 AM, Brandon McCaig wrote: > Looks to me like the problem is that you're not specifying the > time zone for DateTime::now. Try this: > > my $date = DateTime->now(time_zone => $tz); > That's it. I was using the example in the

Re: Current time with DST

2013-04-18 Thread Brian Fraser
On Wed, Apr 17, 2013 at 10:24 PM, Brandon McCaig wrote: > On Thu, Apr 18, 2013 at 01:00:38AM +0100, Ricardo Pais Oliveira wrote: > > Hi! > > Hello, > > > I'm using DateTime::TimeZone to get my current time. Shouldn't daylight > > saving time be handled

Re: Current time with DST

2013-04-18 Thread Dr.Ruud
On 2013-04-18 02:00, Ricardo Pais Oliveira wrote: I'm using DateTime::TimeZone to get my current time. Shouldn't daylight saving time be handled by the DateTime module? In $date I'm obtaining the time with less an hour than it should so I believe DST is not being considered. H

Re: Current time with DST

2013-04-17 Thread Brandon McCaig
On Thu, Apr 18, 2013 at 01:00:38AM +0100, Ricardo Pais Oliveira wrote: > Hi! Hello, > I'm using DateTime::TimeZone to get my current time. Shouldn't daylight > saving time be handled by the DateTime module? > > In $date I'm obtaining the time with less an hour tha

Current time with DST

2013-04-17 Thread Ricardo Pais Oliveira
Hi! I'm using DateTime::TimeZone to get my current time. Shouldn't daylight saving time be handled by the DateTime module? In $date I'm obtaining the time with less an hour than it should so I believe DST is not being considered. How can I obtain the current time regardless it&#

Re: Time::Local (how to handle bad input)

2013-01-09 Thread Bill Stephenson
On Jan 9, 2013, at 11:26 AM, Andy Bach wrote: > On Wed, Jan 9, 2013 at 10:11 AM, Bill Stephenson wrote: > >> date=11/01/2003 >> >> I want to trap bad data sent to time::local in a loop where I use these >> lines: >> >>my ($date_month, $date_d

Re: Time::Local (how to handle bad input)

2013-01-09 Thread Andy Bach
On Wed, Jan 9, 2013 at 10:11 AM, Bill Stephenson wrote: > date=11/01/2003 > > I want to trap bad data sent to time::local in a loop where I use these > lines: > > my ($date_month, $date_day, $date_year) = split(/\//, > $DOCUMENT->param("date")); > &g

Time::Local (how to handle bad input)

2013-01-09 Thread Bill Stephenson
I have a cgi script that processes a bunch of files that have a date in them that should be formatted like so: date=11/01/2003 I want to trap bad data sent to time::local in a loop where I use these lines: my ($date_month, $date_day, $date_year) = split(/\//, $DOCUMENT->param(&q

Re: Time based processes

2012-07-25 Thread punit jain
Hi Below is my script where alarm is generated after 15 sec and changes the global variable in parent from 0 to 1. Is there any mistake in my multiprocess approach with time-based stop ? #!/usr/bin/perl use strict; use warnings; use Parallel::ForkManager; my $MAX_PROC=2; $|++; my $stopFlag=0

Re: Time based processes

2012-07-21 Thread Dr.Ruud
On 2012-07-21 19:16, punit jain wrote: for my $step ( @steps ) { last if $STOP; I would think the issue here is if the list is 30K long and we are still at 2K why would be really like to process whole list ? We can die or handle exit of the script gracefully in my understanding. Is my und

Re: Time based processes

2012-07-21 Thread punit jain
> > > for my $step ( @steps ) { >last if $STOP; > > > I would think the issue here is if the list is 30K long and we are still > at 2K why would be really like to process whole list ? > We can die or handle exit of the script gracefully in my understanding. > > Is my understanding correct here

Re: Time based processes

2012-07-21 Thread Dr.Ruud
On 2012-07-21 16:20, Dr.Ruud wrote: On 2012-07-21 15:41, punit jain wrote: You can let the ALRM-sub simply set a global variable, like $STOP. Your process should check this before starting a next iteration. I suppose this needs to be set in parent process which means Signal needs to be invok

Re: Time based processes

2012-07-21 Thread Dr.Ruud
On 2012-07-21 15:41, punit jain wrote: You can let the ALRM-sub simply set a global variable, like $STOP. Your process should check this before starting a next iteration. I suppose this needs to be set in parent process which means Signal needs to be invoked in parent. Is my understanding corr

Re: Time based processes

2012-07-21 Thread punit jain
Also for :- > for my $step ( @steps ) { last if $STOP; I would think the issue here is if the list is 30K long and we are still at 2K why would be really like to process whole list ? We can die or handle exit of the script gracefully in my understanding.

Re: Time based processes

2012-07-21 Thread punit jain
For the case which you mentioned :- >You can let the ALRM-sub simply set a global variable, like $STOP. Your process should check this before starting a next iteration. I suppose this needs to be set in parent process which means Signal needs to be invoked in parent. Is my understanding correct ?

Re: Time based processes

2012-07-21 Thread Dr.Ruud
On 2012-07-21 15:30, Dr.Ruud wrote: On 2012-07-21 14:50, punit jain wrote: *(B) How do I stop the script graceful without killing the processes and stop from other sunbprocesses being spanned ?* Just let $SIG{INT} and $SIG{TRM} also set $STOP. s/TRM/TERM/ See `kill -l` for the names. Pe

Re: Time based processes

2012-07-21 Thread Dr.Ruud
On 2012-07-21 14:50, punit jain wrote: *(B) How do I stop the script graceful without killing the processes and stop from other sunbprocesses being spanned ?* Just let $SIG{INT} and $SIG{TRM} also set $STOP. Per child you can update $0, to be able to watch the status of the process in ps.

Re: Time based processes

2012-07-21 Thread Dr.Ruud
On 2012-07-21 14:50, punit jain wrote: I have a requirement where I need to run my perl script for x hours You can let the ALRM-sub simply set a global variable, like $STOP. Your process should check this before starting a next iteration. Beware that each child needs its own alarm. The parent

Time based processes

2012-07-21 Thread punit jain
gt;start($acct) and next; -- -- -- Here comes my specific task for subprocess -- -- $pmgr->finish(); } $pmgr->wait_all_children(); return \%data; } Since at a time I am running X- Processes, I dont want them to hardkill as each thread is doing critical atomic operation. How can I st

RE: lets post this nightmare for the 10th time

2012-05-29 Thread Jack Maney
Do you mean: print FILE $_; ? I'd recommend taking a look at what you're actually capturing in your data structures by using Data::Dumper (https://metacpan.org/module/Data::Dumper). -Original Message- From: Ken Furff [mailto:frazzmata...@gmail.com] Sent: Monday, May 28, 2012 3:16

Re: lets post this nightmare for the 10th time

2012-05-28 Thread Jim Gibson
Why did you post the same message four times within 10 minutes? It doesn't make people want to help you. Have you read the documentation for the Spreadsheet::ParseExcel module? You can enter the command 'perldoc Spreadsheet::ParseExcel' or point a browser at

lets post this nightmare for the 10th time

2012-05-28 Thread Ken Furff
I am trying to write a script that pulls some data out of certain columns in a spreadsheet and loads them into an array for comparing and updating. I am having trouble actually seeing the data, it keeps giving me a HASH message. the code is this: @{$sheet->{Cells}$row}; my @indexes = (2 .. (2+

Re: Updating my IP address in real time

2012-05-03 Thread Lawrence Statton
On 05/03/2012 01:44 PM, Terry Shepherd wrote: I like the idea of it being in our zone. Yes, I am running bind - can I hire you to help me configure the server for this? I think I can do it, but it looks like you have done this before already. Yes, I'd be glad to. Let's go off-list and set

Re: Updating my IP address in real time

2012-05-03 Thread Terry Shepherd
g "authoritative" in DNS > is way beyond the scope of this list ... what I really MEANT to say > is the "origin server" (I think that's the name -- it has been a *long* > time since I've had to quote chapter and verse from the DNS RFCs) > > It

Re: Updating my IP address in real time

2012-05-03 Thread Lawrence Statton
sloppy in my answer - a server being "authoritative" in DNS is way beyond the scope of this list ... what I really MEANT to say is the "origin server" (I think that's the name -- it has been a *long* time since I've had to quote chapter and verse from the DNS R

Re: Updating my IP address in real time

2012-05-03 Thread Uri Guttman
On 05/03/2012 01:25 PM, Terry Shepherd wrote: For a project at work, I need to have my development machine here at my house reachable via a name. I don't have static IP from my ISP (they offer it, but it's an expensive add-on). I have the router configured so that if you go to http://205.178.x.

Re: Updating my IP address in real time

2012-05-03 Thread Terry Shepherd
Wow. Thanks for the fast response. This is amazing. No, I did not work for that station. I am in San francisco and was in elementary school during the 80s. What does fqdn mean and what is the authoritave server? On Thu, May 3, 2012 at 12:52 PM, Lawrence Statton wrote: > On 05/03/2012 12:25 P

Re: Updating my IP address in real time

2012-05-03 Thread Lawrence Statton
On 05/03/2012 12:25 PM, Terry Shepherd wrote: For a project at work, I need to have my development machine here at my house reachable via a name. I don't have static IP from my ISP (they offer it, but it's an expensive add-on). I have the router configured so that if you go to http://205.178.x.

Re: Updating my IP address in real time

2012-05-03 Thread Leopoldo Caballero
Actually you can do this with ddclient and a service like DynDNS. Maybe you can put your somehost.mydomain.com in CNAME of blabla.dyndns.org and configure ddclient to update the service for blabla.dyndns.org On Thu, May 3, 2012 at 12:25 PM, Terry Shepherd wrote: > For a project at work, I need t

Updating my IP address in real time

2012-05-03 Thread Terry Shepherd
For a project at work, I need to have my development machine here at my house reachable via a name. I don't have static IP from my ISP (they offer it, but it's an expensive add-on). I have the router configured so that if you go to http://205.178.x../mypage you get to my server, but I need to hav

Re: Seek string to time module

2012-04-24 Thread Michael Rasmussen
On 2012-04-24 07:22, Brent Clark wrote: Hiya Is there a module to parse time. I.e. 00:01:20. The idea was to convert a string, i.e. time, and then to see if the time given is greater than a threshold, for example 1 hour. Hope I make sense. If anyone could help, it would be appreciated. It

Seek string to time module

2012-04-24 Thread Brent Clark
Hiya Is there a module to parse time. I.e. 00:01:20. The idea was to convert a string, i.e. time, and then to see if the time given is greater than a threshold, for example 1 hour. Hope I make sense. If anyone could help, it would be appreciated. Kind Regards Brent Clark -- To unsubscribe

Problems in dates and time additions by one minute.

2011-12-18 Thread Raheel Hassan
i have to match only the date and time and that is working fine for me. I have problems in handling the time because first initial time and end time will be entered by the user but after how i can manipulate it because the time will increase by the addition of one minute and so on till the end

RE: Problems in dates and time additions by one minute.

2011-12-18 Thread Lou Pereira
How do I unsubscribe from this list?? I tried a few times without success! -Original Message- From: Raheel Hassan [mailto:raheel.has...@gmail.com] Sent: Saturday, December 17, 2011 5:58 PM To: beginners@perl.org Subject: Problems in dates and time additions by one minute. Hi, I

Re: Problems in dates and time additions by one minute.

2011-12-17 Thread John W. Krahn
read these files from from the first date(Dec 5 09:02:01) till the last date (Dec 17 17:34:02) in the file. Then i have to search a word between the time difference of one minute and i have to count that how many times that word is present between these two time period. For example : Start time

Problems in dates and time additions by one minute.

2011-12-17 Thread Raheel Hassan
Hi, I have 3 files (these are the log files of the system). These files have date formate like this (Dec 5 09:02:01). I need to read these files from from the first date(Dec 5 09:02:01) till the last date (Dec 17 17:34:02) in the file. Then i have to search a word between the time difference of

Re: script takes long time to run when comparing digits within strings using foreach

2011-05-28 Thread John W. Krahn
27;, '1 2 3 4 5 9' , '6 7 8 9 10 11'); Now I wish to compare each element of @datas with the rest of the elements in @datas in such a way that if 5 of the digits match, to take note of the matching indices, and so the script I wrote is appended below. However, the script below takes

Re: script takes long time to run when comparing digits within strings using foreach

2011-05-28 Thread Dr.Ruud
On 2011-05-27 10:18, eventual wrote: I have an array , @datas, and each element within @datas is a string that's made up of 6 digits with spaces in between like this “1 2 3 4 5 6”, so the array look like this @datas = ('1 2 3 4 5 6', '1 2 9 10 11 12', '1 2 3 4 5 8', '1 2 3 4 5 9' , '6 7 8 9 1

Re: script takes long time to run when comparing digits within strings using foreach

2011-05-27 Thread Shlomi Fish
e > script I wrote is appended below. However, the script below takes a long > time to run if the datas at @datas are huge( eg 30,000 elements). I then > wonder is there a way to rewrite the script so that the script can run > faster. Thanks > > ## script below ##

script takes long time to run when comparing digits within strings using foreach

2011-05-27 Thread eventual
'6 7 8 9 10 11'); Now I wish to compare each element of @datas with the rest of the elements in @datas in such a way that if 5 of the digits match, to take note of the matching indices,  and so the script I wrote is appended below. However, the script below takes a long time to run i

Re: Rounding Date/Time

2011-05-06 Thread Peter Scott
On Mon, 02 May 2011 11:46:42 -0500, Matt wrote: > Have a date: > > 2011-05-02-16:40:51 [...] > > I need to round it to nearest 5 minute point. > > 2011-05-02-16:40:51 If you care about things like daylight savings time adjustments, calendar changes, or leap seconds

Re: Rounding Date/Time

2011-05-05 Thread Pete Smith
eers, Pete use DateTime; use DateTime::Duration; use Math::Round 'nearest'; # create a DateTime object for now - see the docs: # http://search.cpan.org/perldoc?DateTime my $dt = DateTime->now; # you should set time zone as you may be in DST $dt->set_time_zone( 'Europe/London

Re: Rounding Date/Time

2011-05-04 Thread Rob Dixon
On 04/05/2011 18:14, C.DeRykus wrote: On May 3, 4:12 pm, rob.di...@gmx.com (Rob Dixon) wrote: On 03/05/2011 19:49, C.DeRykus wrote: use Time::localtime; use List::Util qw/reduce/; my @rounded_5mins = grep { not $_ % 5 } 0..60; my $curr_min = localtime->min; my $round_min = red

Re: Rounding Date/Time

2011-05-04 Thread C.DeRykus
gt; I need to round it to nearest 5 minute point. > > >> 2011-05-02-16:40:51 > > >> needs rounded like so. > > >> 2011-05-02-16:00:00 > >> 2011-05-02-16:45:00 > >> 2011-05-02-16:50:00 > >> 2011-05-02-16:55:00 > > >> My thought is

Re: Rounding Date/Time

2011-05-03 Thread Rob Dixon
ere a better/easier way? Yet another way using the core module List::Util: use Time::localtime; use List::Util qw/reduce/; my @rounded_5mins = grep { not $_ % 5 } 0..60; my $curr_min = localtime->min; my $round_min = reduce { $curr_min-$a< $b-$curr_min ? $a : $b }

Re: Rounding Date/Time

2011-05-03 Thread C.DeRykus
On May 3, 11:54 am, shawnhco...@ncf.ca (Shawn H Corey) wrote: > On 11-05-03 02:49 PM, C.DeRykus wrote: > > > my @rounded_5mins = grep { not $_ % 5 } 0..60; > > my @rounded_5mins = map { $_ * 5 } 0..12; > > # TIMTOWTDI > Make that: TIMTOWTDI++ # a much better way to do it -- Charles DeRykus -

Re: Rounding Date/Time

2011-05-03 Thread Shawn H Corey
On 11-05-03 02:49 PM, C.DeRykus wrote: my @rounded_5mins = grep { not $_ % 5 } 0..60; my @rounded_5mins = map { $_ * 5 } 0..12; # TIMTOWTDI -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding. Programming is as much about organization and commu

Re: Rounding Date/Time

2011-05-03 Thread C.DeRykus
thought is a bunch of if statements but that seems ugly.  Is there > a better/easier way? Yet another way using the core module List::Util: use Time::localtime; use List::Util qw/reduce/; my @rounded_5mins = grep { not $_ % 5 } 0..60; my $curr_min = localtime->min; my $round_min = re

Re: Rounding Date/Time

2011-05-03 Thread Rob Dixon
r to round to the nearest five minutes while the time is held in epoch seconds. Instead of letting gmtime() do an implicit call to time(), you can do an explicit one, round the result, and pass it to gmtime() for reformatting. The code below shows my point. HTH, Rob use strict; use warnings; us

Re: Rounding Date/Time

2011-05-02 Thread Jim Gibson
day, $tm->hour, $tm->min, $tm->sec; > print "$time_stamp\n"; That program fragment does not run on my system: "Can't locate object method "year" via package "Mon May 2 17:16:09 2011" (perhaps you forgot to load "Mon May 2 17:16:09 2011&qu

Re: Rounding Date/Time

2011-05-02 Thread Uri Guttman
;hour, $tm->min, $tm->sec; M> print "$time_stamp\n"; use POSIX strftime for that. i have seen experienced hacker code not using that call. it provides dozens of time format outputs including all the common ones and several groups of them too. same format as the date unix comm

Rounding Date/Time

2011-05-02 Thread Matt
Have a date: 2011-05-02-16:40:51 Using this to get it: $tm = gmtime; $time_stamp = sprintf "%04d-%02d-%02d-%02d:%02d:%02d", $tm->year + 1900, $tm->mon + 1, $tm->mday, $tm->hour, $tm->min, $tm->sec; print "$time_stamp\n"; I need to round it to nearest 5 minute point. 2011-05-02-16:40:51 needs

Re: time format conversion

2011-04-21 Thread Karl Kaufman
- Original Message - From: "Rob Dixon" To: Cc: "shawn wilson" Sent: Thursday, April 21, 2011 1:14 PM Subject: Re: time format conversion On 21/04/2011 10:52, shawn wilson wrote: If its always in that format, just split and define a hash and pass it t

Re: time format conversion

2011-04-21 Thread Rob Dixon
rs, not the variables. Is there a function that can do this? I don't think there is much to do with time and dates that dt (or other modules under that namespace) can't handle. I agree. DateTime is probably the answer, but I think you are misleading people by referring to dt (or othe

Re: time format conversion

2011-04-21 Thread shawn wilson
On Apr 21, 2011 12:17 PM, "Karl Kaufman" wrote: > > Alternatives to shawn's response (w/o commenting on relative benefits)... You won't mention the benefits, but I will... :) > > - Original Message - From: "cc" > To: > Sent: Thursda

Re: time format conversion

2011-04-21 Thread Karl Kaufman
Alternatives to shawn's response (w/o commenting on relative benefits)... - Original Message - From: "cc" To: Sent: Thursday, April 21, 2011 4:37 AM Subject: time format conversion Hi, I have two strings that shows different times and I want to find the differenc

Re: time format conversion

2011-04-21 Thread shawn wilson
wise, use dt:format:natural. > So if t1 and t2 are of the aforementioned format, > I just do a t2 - t1 and it should give me > the # of hours between the two datetimes. > As stated in the doc, dt overloads the variables so that you can do that easy enough. > Is there a function that can

time format conversion

2011-04-21 Thread cc
Hi, I have two strings that shows different times and I want to find the difference in # of hours. In PHP, there's strtotime(), but there isn't one in Perl that I can find. The string format is: mm/dd/ hh:mm:ss So if t1 and t2 are of the aforementioned format, I just do a t2 - t1 and it sho

RE: Excessive wait time after fork

2011-04-06 Thread TAO, NENGBING [AG/1005]
- From: TAO, NENGBING [AG/1005] Sent: Saturday, April 02, 2011 11:07 AM To: 'beginners-digest-h...@perl.org'; beginners@perl.org Subject: Excessive wait time after fork Hi, I noticed that after fork, the wait time is excessive (my other test waited for hours). Is this a known

RE: Excessive wait time after fork

2011-04-06 Thread TAO, NENGBING [AG/1005]
id show that less than half of the total memory is used. So I don't believe the server is swamped. Thanks -Original Message- From: Chas. Owens [mailto:chas.ow...@gmail.com] Sent: Monday, April 04, 2011 6:40 AM To: TAO, NENGBING [AG/1005] Cc: beginners-digest-h...@perl.org; begi

Re: Excessive wait time after fork

2011-04-04 Thread Chas. Owens
On Sat, Apr 2, 2011 at 12:06, TAO, NENGBING [AG/1005] wrote: > Hi, > >        I noticed that after fork, the wait time is excessive (my other > test waited for hours). Is this a known problem, how to get around it? snip > child 3 AFTER  sub call :Sat Apr  2 10:45:01 2011 numKeys:40

Excessive wait time after fork

2011-04-04 Thread TAO, NENGBING [AG/1005]
Hi, I noticed that after fork, the wait time is excessive (my other test waited for hours). Is this a known problem, how to get around it? This happens with ForkManager module also. Any pointers on what's going on is appreciated!

Re: Building an image one pixel at a time

2011-03-30 Thread Shawn H Corey
On 11-03-30 03:29 PM, Bryan R Harris wrote: I don't have any yet. I was just wondering if there was a module that would write out .png files reliably... There's a number of them. Try GD to start. http://search.cpan.org/~lds/GD-2.45/GD.pm -- Just my 0.0002 million dollars worth, Shawn

Re: Building an image one pixel at a time

2011-03-30 Thread Bryan R Harris
> On 11-03-30 11:36 AM, Bryan R Harris wrote: >> >> >> All, >> >> Is it possible to build an image one pixel at a time, e.g. to have a data >> structure that looks like this: >> >> $i{channel}[x][y] >> >> ... where channel is r,

Re: Building an image one pixel at a time

2011-03-30 Thread Shawn H Corey
On 11-03-30 11:36 AM, Bryan R Harris wrote: All, Is it possible to build an image one pixel at a time, e.g. to have a data structure that looks like this: $i{channel}[x][y] ... where channel is r,g,b, or a, and x and y are the pixel coordinates. Then, once I have the data filled out, call

Building an image one pixel at a time

2011-03-30 Thread Bryan R Harris
All, Is it possible to build an image one pixel at a time, e.g. to have a data structure that looks like this: $i{channel}[x][y] ... where channel is r,g,b, or a, and x and y are the pixel coordinates. Then, once I have the data filled out, call some module and write out a .png file? - Bryan

Re: Scan/Parse directory for "newest" file, print file timestamp and compute date/time difference - Some advice please

2011-03-02 Thread Jim Gibson
file.03 03-Jan-2011 0500 > .. > .. > /backup/file.31 31-Jan-2011 0500 > /backup/file.32 01-Feb-2011 0500 > /backup/file.33 02-Feb-2011 0500 > > I want the script to check the most recent file in a backup directory, i.e. > newest, for example /backup/file.33 and disp

  1   2   3   4   5   6   7   8   9   10   >