Anonymous Monk:
If you had looked at the output, you'd see some hints that would guide you to the right answer:
- Use of uninitialized value $1... line 7
Here, perl is trying to tell you that the variable $1 doesn't have a value. Looking at your code, I expect you meant to use $d1 instead. Since 2019-06-08 is greater than *nothing*, the true result is actually correct.
- Argument "2019-06-08" isn't numeric... line 7
Perl is now telling you that you're comparing values incorrectly. Since you're using a good date format "YYYY-MM-DD" (I'm guessing), then you can use a simple
comparison like the "cmp" function (compares alphabetically). If instead you're using "YYYY-DD-MM", then a simple comparison like that would fail and you'd need to do something fancier (such as my last comment below). If you really wanted to use a numeric comparison, you'd want to convert the values to numbers
first.
Or you could use a Date handling module from http://cpan.org to handle the date parsing and comparison.
...roboticus
When your only tool is a hammer, all problems look like your thumb.