in reply to Calculate date with days

use Data::Dumper; use strict; use warnings; my $offset = 3; print Dumper(localtime(time())); print "\n"; print Dumper(localtime(time() + 24 * 3600 * $offset));

Replies are listed 'Best First'.
Re^2: Calculate date with days
by darrengan (Sexton) on Aug 24, 2005 at 05:13 UTC
    hie pg, i am totally new to perl. for the Data::Dumper, do i need to install this component or it is already included in the system? Cheers, Darren

      Data::Dumper is actually not needed, and it was just a handy way to display the result:

      use strict; use warnings; my $offset = 3; display(reverse((localtime(time()))[0 .. 5])); display(reverse((localtime(time() + 24 * 3600 * $offset))[0 .. 5])); sub display { my @t = @_; printf("%d-%02d-%02d-%02d:%02d:%02d\n", $t[0] + 1900, $t[1] + 1, @ +t[2 .. 5]); }
      Data::Dumper is a core perl Module i.e. should come with Perl. Check the link to see more information about it.

      A simple use case

      #!/usr/bin/perl use Data::Dumper; use strict; use warnings; my @list = qw (hi there); print Dumper(@list);

      Output

      $VAR1 = 'hi'; $VAR2 = 'there';