Using Perl to compare dates

I have created a grade book for myself to record my student's math grades. I want to compare the date that I gave the assignment with the quarter's beginning and ending date to show all grades for a given quarter.
if ( $assgndate >= $begdate && $assigndate <= $enddate).....

I have used Date::Manip to assist me with the comparison but when I few the error logs
I get error the following type of messages:

[ERROR]{ARGUMENT 20043xxxx is numeric in ge ( >=)...
I also get the same reply for the <= comparison, too

The script does work. I was just curious is there a better, hopefully easier, way to compare dates?

Who is Participating?
TintinConnect With a Mentor Commented:
If you are using ISO date formats, then you don't need a big, clumsy module like Date::Manip (unless you are doing other complicated date comparisons)

So if you have:


Then doing

if ($assigndate >= $begdate and $assigndate <= $enddate) {
    print "$assigndate is within the begin and end dates\n";

The error message you mention (although you missed a *very* important word, ie: "is" should be "isn't") is caused by one of the variables being non-numeric.

For example:

$ cat date
print if ($a >= 'a');

$ perl -w date
Argument "a" isn't numeric in numeric ge (>=) at date line 2.
Use of uninitialized value in print at date line 2.
could you please post the assignemts to these variables
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.