Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^4: Newbie: Request help on creating CSV using timestamp data

by Anonymous Monk
on Nov 25, 2013 at 10:34 UTC ( #1064209=note: print w/ replies, xml ) Need Help??

in reply to Re^3: Newbie: Request help on creating CSV using timestamp data
in thread Newbie: Request help on creating CSV using timestamp data

Using the perl version --> v5.8.8 built. Getting the following error using the above snippet,

Use of uninitialized value in addition (+)

Comment on Re^4: Newbie: Request help on creating CSV using timestamp data
Download Code
Re^5: Newbie: Request help on creating CSV using timestamp data
by Tux (Monsignor) on Nov 25, 2013 at 11:57 UTC

    Is it possible that you are still using a module that overrides the builtin localtime function? I did mention that my example did use the builtin. (to be complete, I tested the same with use Time::Local; and use Time::Piece;, and both passed too).

    I ran my piece of example code through every version of perl ever released since 5.6.0, and they all work as expected. Here is the shortened list of results (I skipped all development releases and older versions of stable branches, but included 5.8.8):

    $ cat use strict; use warnings; sub timestamp { my @st = localtime (shift); return sprintf "%04d-%02d-%02dT%02d:%02d:%02d.000-0700", $st[5] + 1900, ++$st[4], @st[3,2,1,0]; } sub starttimestamp { return timestamp (time); } sub endtimestamp { return timestamp (time + (15 * 60)); } sub futuretimestamp { return timestamp (time + shift); } my $fts = futuretimestamp (162 * 60 * 60); # Stamp 162 hours ahead print $fts, "\n"; $ perl-all === base/perl5.6.2 5.006002 i686-linux-64int-perlio 2013-12-02T06:46:51.000-0700 === base/tperl5.6.2 5.006002 i686-linux-thread-multi-64int-ld-perli +o 2013-12-02T06:46:52.000-0700 === base/perl5.8.8 5.008008 i686-linux-64int 2013-12-02T06:46:56.000-0700 === base/tperl5.8.8 5.008008 i686-linux-thread-multi-64int-ld 2013-12-02T06:46:56.000-0700 === base/perl5.8.9 5.008009 i686-linux-64int 2013-12-02T06:46:56.000-0700 === base/tperl5.8.9 5.008009 i686-linux-thread-multi-64int-ld 2013-12-02T06:46:57.000-0700 === base/perl5.10.1 5.010001 i686-linux-64int 2013-12-02T06:46:58.000-0700 === base/tperl5.10.1 5.010001 i686-linux-thread-multi-64int-ld 2013-12-02T06:46:58.000-0700 === base/perl5.12.5 5.012005 i686-linux-64int 2013-12-02T06:47:05.000-0700 === base/tperl5.12.5 5.012005 i686-linux-thread-multi-64int-ld 2013-12-02T06:47:05.000-0700 === base/cperl5.14.4 5.014004 i686-linux-64int-ld 2013-12-02T06:47:15.000-0700 === base/perl5.14.4 5.014004 i686-linux-64int 2013-12-02T06:47:16.000-0700 === base/tperl5.14.4 5.014004 i686-linux-thread-multi-64int-ld 2013-12-02T06:47:16.000-0700 === base/cperl5.16.3 5.016003 i686-linux-64int-ld 2013-12-02T06:47:25.000-0700 === base/perl5.16.3 5.016003 i686-linux-64int 2013-12-02T06:47:25.000-0700 === base/tperl5.16.3 5.016003 i686-linux-thread-multi-64int-ld 2013-12-02T06:47:26.000-0700 === base/cperl5.18.2 5.018002 i686-linux-64int-ld 2013-12-02T06:47:36.000-0700 === base/perl5.18.2 5.018002 i686-linux-64int 2013-12-02T06:47:37.000-0700 === base/tperl5.18.2 5.018002 i686-linux-thread-multi-64int-ld 2013-12-02T06:47:37.000-0700

    Enjoy, Have FUN! H.Merijn

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1064209]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2014-10-31 04:19 GMT
Find Nodes?
    Voting Booth?

    For retirement, I am banking on:

    Results (214 votes), past polls