Find the answer to your Linux question:
Results 1 to 4 of 4
Is there any way to compare two dates in Perl ???...
  1. #1
    Linux Newbie
    Join Date
    Jan 2008
    Posts
    114

    Is there any way to compare two dates in Perl ???

    Is there any way to compare two dates in Perl ???
    Switched to Scripting

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Is there any way to compare two dates in Perl ?
    Probably. How do you first come across these dates? As attributes of files? As strings? If as strings, what do the strings look like?
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Linux Newbie
    Join Date
    Jan 2008
    Posts
    114
    As a string see following, i know below one can not work but just for example what I am looking for:-

    my $curr_date =`date +\%Y-\%m-\%d`;

    chomp($curr_date);

    if ($curr_date >= '2008-03-04') {
    print "date is greater than/equal to current date";
    } else { print "date is less than or check the date" ;}
    Switched to Scripting

  4. #4
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Code:
    if ($curr_date ge '2008-03-04')
    You wouldn't be explicitly comparing dates there, you'd be comparing strings, like two surnames in a phone book. But it works.
    --
    Bill

    Old age and treachery will overcome youth and skill.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...