Perl treats both your variables as strings. The operators compare your strings in 'dictionary' order. This really does not seem to make any sense for dates formatted as you have them. A common idiom is to store dates as yyyymmdd. You still cannot do arithmetic on them, but you can compare and sort them with perl's built-in comparison operators.

Note: Your example is a special case (Only one field is different between the two dates) where your code does work correctly. Good Luck, Bill

Your example is entirely correct, but if you use the YYYY-MM-DD format (which you suggested as an alternative), then you should use the lt string comparison operator rather than the < numerical comparison operator.

The code you posted won't compile due to the missing semicolons on the assignment statements. Assuming that was simply a typo when posting, the next problem is that the "dates" aren't actually date strings due to the missing quotes. They are mathematical equations (12 divided by 4 divided by 2015) which is why they resulted in floats.

Bulrush's solution assigns the dates as strings but uses a numerical operator when comparing them, which works in this case/context but not all.