The following works for the range of formats you have given.

use strict; use warnings; my %months = ( january => 'jan', february => 'feb', march => 'mar', april => 'apr', may => 'may', june => 'jun', july => 'jul', august => 'aug', september =>'sep', october => 'oct', november => 'nov', december => 'dec', ); my %monthCvt = ( jan => 1, feb => 2, mar => 3, apr => 4, may => 5, jun => 6, jul => 7, aug => 8, sep => 9, oct => 10, nov => 11, dec => 12, ); while (<DATA>) { chomp; $_ = lc $_; # Strip leading spaces s/\s*//; # Normalize month s/([a-z]+)/$months{$1} || $1/e; # Normalize punctuation s|[ -/,.\\]+| |g; # Normalize order: month day year s|^(\d+)\s([a-z]+)|$2 $1|; # Extract fields my ($month, $day, $year) = /(\w+) (\d+) (\d+)/; # Month to numeric form if required $month = $monthCvt{$month} if $month !~ /\d/; print "$month/$day/$year\n"; } __DATA__ Sep 29 2005 Jun 30, 2003 December 15 2005 December 31, 2004 06-Dec-2005 10-19-2005

Prints:

9/29/2005 6/30/2003 12/15/2005 12/31/2004 12/06/2005 10/19/2005

DWIM is Perl's answer to Gödel

In reply to Re: Multiple date format by GrandFather
in thread Multiple date format by kulls

Title:
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, details, 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, summary, 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.