Hi, Requirement - I have file name called "Rajesh.1202242219". Numbers are nothing but a date "`date '+%y''%m''%d''%H''%M'`" format. Now I am trying to write a perl script to extract the numbers from file name and compare with current system date and time and based on output of this comparison, print some value using perl. Approach: Extract the Digit from File name:
if ($file =~ /Rajesh.(\d+).*/) { print $1; }
Convert this time into readable time in perl
my $sec = 0; # Not Feeded my $min = 19; my $hour = 22; my $day = 24; my $mon = 02 - 1; my $year = 2012 - 1900; my $wday = 0; # Not Feeded my $yday = 0; # Not Feeded my $unixtime = mktime ($sec, $min, $hour, $day, $mon, $year, $wday, $y +day); print "$unixtime\n"; my $readable_time = localtime($unixtime); print "$readable_time\n";
find Current time and compare...
my $CurrentTime = time(); my $Todaydate = localtime($startTime);
But the problem here is, I am not getting solution of how to extract 2 digit from $1 and assign to $sec, $min, etc... Any help????? Also, if you have good approach for this problem statement, Please share with me

In reply to Convert Old Unix Date to Perl and compare by rajeshatbuzz

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.