Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > date --date : the perl way

Reply
Thread Tools

date --date : the perl way

 
 
Me
Guest
Posts: n/a
 
      12-09-2005

I need to get the past 5(x) months for certaing calculations. What I
have is listed below:

########################################
my $year, $month_str, $month_int;


foreach my $count (1..5) {
$year = `date --date '$count months ago' +"%Y"`;
chop($year);
$month_str =`date --date '$count months ago' +"%b"`;
chop($month_str);
$month_int =`date --date '$count months ago' +"%m"`;
chop($month_int);
print "\n $year:$month_str:$month_int";

}
########################################

This works as expected, the problem is I am using a shell command and I
would like to move away from it. Is the perl module that is able to take
parameters juat like the 'date' command?
 
Reply With Quote
 
 
 
 
Eric J. Roode
Guest
Posts: n/a
 
      12-09-2005
Me <(E-Mail Removed)> wrote in news:(E-Mail Removed):

> This works as expected, the problem is I am using a shell command and I
> would like to move away from it. Is the perl module that is able to take
> parameters juat like the 'date' command?


There are many date-processing modules. None (that I know of) take
parameters that match those of the `date` command, but most of them provide
ways of specifying what you're looking for.

Have you looked at CPAN?

P.S.: comp.lang.perl is a defunct newsgroup. General perl questions are to
be posted to comp.lang.perl.misc, and questions about modules are to be
posted to comp.lang.perl.modules. For your future postings.

--
Eric
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Given a date, how to find the beginning date and ending date of that week Matt ASP General 11 11-08-2003 11:24 PM
Given a date, how to find the beginning date and ending date of that week Matt ASP .Net 1 11-08-2003 09:14 PM
Given a date, how to find the beginning date and ending date of that week Matt C Programming 3 11-08-2003 09:07 PM
Given a date, how to find the beginning date and ending date of that week Matt C++ 2 11-08-2003 08:30 PM



Advertisments