Reputation: 1333
Just interested at this kind of comparison, any clue?
Say there are two variables as below:
$p1 = "2013-01-11/2013-01-04";
$p2 = "2013-01-12/2012-01-05";
If like below codes in Perl,
if $p1 lt $p2
What Perl will take to compare and how?
Upvotes: 1
Views: 108
Reputation: 31745
Breaking down your tasks:
if $p1 < $p2
This question:
Convert string "20-May-07" to date and manipulate
will give you some leads
Upvotes: -1
Reputation: 13456
lt
is string comparation operator, and it compares two operands in their literal sense.
In your case, two strings
2013-01-11/2013-01-04
||||||||||
2013-01-12/2012-01-05
will be compared in the illustrated manner, and stop at the 9th position (the first position characters are different, also note string index starts at 0), i.e. 1
in $p1
and 2
in $p2
. And also 1
is less than 2
literally. So $p1 lt $2
is true.
Upvotes: 7