Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Two Weeks

by ImpalaSS (Monk)
on Nov 20, 2000 at 20:22 UTC ( [id://42517]=perlquestion: print w/replies, xml ) Need Help??

ImpalaSS has asked for the wisdom of the Perl Monks concerning the following question:

I am working on a project at work, and it calls for a dropdown box to display everydate, from today to the past 2 weeks. So it would have these choices, Today, 19Nov00, 18Nov00..ect. This box would be updated everyday, and would drop the last date to add the new one. What is the best way to display just the past 2 weeks, in that format?
Thank You


Replies are listed 'Best First'.
Re: Two Weeks
by merlyn (Sage) on Nov 20, 2000 at 20:35 UTC
(Date::) Re: Two Weeks
by mwp (Hermit) on Nov 20, 2000 at 20:25 UTC
    Date::Manip, or if you need the speed Date::Calc. =)

    "Who gave HIM a Perl interpreter?!"


    #!/usr/bin/perl -w use strict; use Date::Manip qw(ParseDate DateCalc UnixDate); foreach my $i (0..13) { # create a date by subtracting iterator ($i) days from today my $date = &DateCalc('today', "-$i days"); # print the formatted date (DDmmmYY) print &UnixDate($date, '%d%b%y'), "\n"; }

    merlyn's example is far superior to both Date::Manip and Date::Calc, and you should use that instead if you can.

      One of the problems is i cannot install any modules, for many reasons. Is there a way i can do this w/o the use of a module/funcion that isnt built into perl?


        If you are using ActiveState's Perl for Win32, use PPM. If you are having trouble in Unix, as an alternative to perl -MCPAN -e shell try:
        1. Download the module from CPAN.
        2. Extract the files with tar.
        3. Descend into the module directory and run:
          perl Makefile.PL && make && make check && make install

        And that should do it!

        "Who gave HIM a Perl interpreter?!"

        ImpallaSS, Go to whoever's in charge of these things and say : "I can do this in $time the way things are currently set up. However, if you give me access to the tools I need, including the ability to get modules installed, it could be $time2, saving the company $lots."

        It might be that they have a sysadmin install the modules for you; you might not need to do it on your own. But, based on some of the talk we've had in the chatterbox, you're trying to do a complicated thing that could be simplified a hundred fold if you had access to the correct tools. Explain to management what you need, and why. Present your case in terms of money saved, or time saved.

        You can install modules for your own personal use. I can't install any since I don't have root access here at the university.

        After much searching I discovered if you do:

        perl Makefile.PL LIB='/some/dir' PREFIX='/some/dir'

        You can then use modules you install in /some/dir. You just add:

        use LIB '/some/dir'

        in the top of your Perl program.

        Learning Perl or Going To Die Trying

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://42517]
Approved by root
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-21 12:07 GMT
Find Nodes?
    Voting Booth?

    No recent polls found