in reply to Not able to ParseDate lines from a file

The error message complains about the value for year, to which you pass $time, to which you never assign a value.

Please, always use use strict; use warnings;.

Replies are listed 'Best First'.
Re^2: Not able to ParseDate lines from a file
by xpl0it (Initiate) on Feb 03, 2012 at 10:28 UTC
    The code which I had uploaded was not right. That was a code which I was testing. I have made the changes. Kindly advice. Thanks

      xpl0it:

      Well you still need to check what you're passing in. The error message is quite clearly stating that you're not passing in a valid value for year, so either run your script in debug mode or add some print statements to display values of various variables so you can see what's going on. (For simple quick & dirty stuff, I generally add a print or two, but for tougher problems, I use debug mode.)

      You really ought to familiarize yourself with the debugger, so I suggest trying it out. Run your script like perl -d scriptname.pl and read up on perldebug and have some fun.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

        Yeah! I did that. I put in a few print statements to see what is being printed. So when I execute "print $year", it gives me the desired result, but if the same I put it in the DateTime->new, it gives an error. I read on the DateTime and found that it is expecting an int value. I tried converting the $year to an int, using the int function ... int($year) ... but that made $year to 0. Strange! I read the manuals and did a lot of trials and errors, then since none worked, I thought of putting it up here