views:

313

answers:

2

I have a fairly simple perl script with uses the LWP::UserAgent module to follow URLs through redirection to find the final destination URL which it then stores in our MySQL database. The problem is that from time to time the script reports warnings that look like this:

Day too big - 25592 > 24855
Sec too small - 25592 < 74752
Sec too big - 25592 > 11647
Day too big - 25592 > 24855
Sec too small - 25592 < 74752
Sec too big - 25592 > 11647

The warnings don't provide any other details as to why this is happening or which module is causing the issue but I'm pretty sure it has to do with LWP::UserAgent.

I'm initializing the agent using the following code:

use LWP::UserAgent;
my $ua = LWP::UserAgent->new(cookie_jar => { },requests_redirectable => [ ]);
$ua->agent('Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:9.9.9.9) Gecko/20079999 Firefox/2.0.0.1');
$ua->timeout(10);

I searched online and the only result I found was to the following thread which was never resolved http://www.mail-archive.com/[email protected]/msg06515.html. The thread author thought that these warning were somehow related to cookie dates being captured by the LWP::UserAgent module.

The warning doesn't seem to be effecting the script but I would appreciate any help in better understanding what might be causing this issue and advice on how to resolve it or at least suppress the warning messages. Thanks in advance for your help!

+4  A: 

See Changes:

2009-10-06 Release 5.833

Gisle Aas (5):

  • Deal with cookies that expire far into the future [RT#50147]
  • Deal with cookies that expire at or before epoch [RT#49467]

It looks like you need to upgrade to the most recent version of LWP.

Sinan Ünür
Thanks for figuring this out Sinan! Unfortunately I can't upgrade the module since cPanel uses LWP extensively and it hasn't yet upgraded to 5.833. I'm trying out Hillu's suggestion in the interim.
Russell C.
@Russell C. Since the question is about suppressing those messages, you should probably accept @hillu's answer.
Sinan Ünür
+3  A: 

If upgrading is not an option for you, you can, of course always filter out the warnings using a local $SIG{__WARN__} handler.

{
    local $SIG{__WARN__} = sub {
        warn @_ unless $_[0] =~ m(^.* too (?:big|small));
    };
    # your code here.
}
hillu
@hillu - I had to modify slightly to also suppress 'Sec' instead of just 'Day' but otherwise this worked perfectly. Thanks for your help!
Russell C.
thanks for pointing that out. I modified my example a bit since I imagine that in the imperfect world out there, other fields may may cause similar warnings.
hillu