Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Thanks all for the overwhelming response!! I cracked this one with the CPAN modules Date::Simple and Date::Range. I was able to get the dates in the format I wanted and put all of them in an array.

May be this implementation is a bit "noobish" or elaborate... but it worked! I will definitely make note of all your suggestions, and perhaps, may be get to use it when I face a similar problem in future.

Okay! Here's what I did :D .....

my $date1 = $ARGV[0]; my $date2 = $ARGV[1]; my ( $start, $end ) = ( date($date1), date($date2) ); my $range = Date::Range->new( $start, $end ); my @all_dates = $range->dates; my %hash=("01"=>"Jan","02"=>"Feb","03"=>"Mar","04"=>"Apr","05"=>"May", +"06"=>"Jun","07"=>"Jul","08"=>"Aug","09"=>"Sep","10"=>"Oct","11"=>"No +v","12"=>"Dec"); foreach my $numericDate (@all_dates) { while ( my ($key, $value) = each(%hash) ) { $numericDate =~ s/\-$key-/\-$value\-/g; } } my @tempArray; foreach my $reverseDate (@all_dates) { split (/-/,$reverseDate); my $correctFormat = $_[2]."-".$_[1]."-".$_[0]; push (@tempArray, $correctFormat); } print "\n@tempArray\n";

So, the output looks something like this:

$ ./ 2011-12-10 2011-12-13 ============================== 10-Nov-2011 11-Nov-2011 12-Nov-2011 13-Nov-2011 14-Nov-2011 15-Nov-201 +1 16-Nov-2011 17-Nov-2011 18-Nov-2011 19-Nov-2011 20-Nov-2011 21-Nov- +2011 22-Nov-2011 23-Nov-2011 24-Nov-2011 25-Nov-2011 26-Nov-2011 27-N +ov-2011 28-Nov-2011 29-Nov-2011 30-Nov-2011 01-Dec-2011 02-Dec-2011 0 +3-Dec-2011 04-Dec-2011 05-Dec-2011 06-Dec-2011 07-Dec-2011 08-Dec-201 +1 09-Dec-2011 10-Dec-2011 11-Dec-2011 12-Dec-2011 13-Dec-2011 ==============================
Thanks a ton for all your suggestions!

In reply to Re^2: Extracting Log File data for a given date range by vishi
in thread Extracting Log File data for a given date range by vishi

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [erix]: choroba: pretty impressive! :)
    LanX imagines which nations would be dominating if the winter olympics were invented in East Asia
    [LanX]: Corion: and that's the clue how Germany can dominate Handball tournaments, just continuing the domestic league and forbidding the best players of the world to attend :)
    LanX (which would be a good scheme for England and football too)
    [LanX]: If "Canada will play the Czech Republic for bronze on Saturday", that means Germany will play Syria in disguise...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (9)
    As of 2018-02-23 16:40 GMT
    Find Nodes?
      Voting Booth?
      When it is dark outside I am happiest to see ...

      Results (303 votes). Check out past polls.