Hi,

try this:

use strict; use warnings; my $year = 2013; # hard coded as not in the data my %months = (Jan => "01", Feb => "02", Mar => "03", Other => "...4 5 +6 7 8 9", Oct => 10, Nov => 11, Dec => 12); my $line = <DATA>; my ($date, $rest) = split /,/, $line; my ($mon, $day) = split / /, $date; my $month = $months{$mon}; my $new_date = "$month$day$year"; print $new_date, "\n"; __DATA__ Oct 31 08:30,/home/imanager/cppprod/AR_LM.csv Oct 31 07:32,/home/imanager/cppprod/AddressDevCHUBldgProj.csv Oct 31 08:06,/home/imanager/cppprod/AddressDevCHUBldgProj_LM.csv Oct 31 07:44,/home/imanager/cppprod/BalDue.csv Oct 31 08:07,/home/imanager/cppprod/BalDue_LM.csv Oct 31 07:50,/home/imanager/cppprod/Charges.csv Oct 31 08:10,/home/imanager/cppprod/Charges_LM.csv Oct 31 08:45,/home/imanager/cppprod/Dem_A_C.csv
This outputs this:
$ perl dates.pl 10312013
I would suggest that you use the mkdir Perl internal function, rather that a system call. Something like this:
mkdir $new_date or die "could not create directory $new_date $!";


In reply to Re: Convert date into day and month by Laurent_R
in thread Convert date into day and month by Ma

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.