Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Logfile-NCSA-Undefined Subroutine?

by WhiteBird (Hermit)
on Aug 06, 2003 at 22:16 UTC ( #281619=perlquestion: print w/replies, xml ) Need Help??

WhiteBird has asked for the wisdom of the Perl Monks concerning the following question:


I am trying to pull data out of an NCSA formatted Logfile from an IIS4 server using Perl(v 5.6.1) and the Logfile Module(v 0.300) which I downloaded from CPAN. My code, based on examples from the documentation and from "Data Munging with Perl" is pretty basic:

use strict; use LogFile::Base; use LogFile::Apache; use LogFile::NCSA; my $log = new Logfile::NCSA File => 'C:\\nc030805.log', Group => [qw(Host User Date )]; $log->report(Group => 'Host User Date');
When I try to run it, though, it dies on line 5 with the following error

Undefined subroutine &Time::String::to_time called...Logfile/ line 281,<fh001>

I've run it with a debugger, and it goes along nicely until it hits that section of code in which is a Date parsing routine. My variables appear to be traversing through the code, with @_ containing the entry from my logfile, and $_, $1 and $2 being undef.

Since this is a chunk of code from the module, I think it's out of my control, and I'm stumped. I've done super search, and looked around and don't know what to do next. Would any of you have any idea what's causing this error and what should I do to fix it?

Replies are listed 'Best First'.
Re: Logfile-NCSA-Undefined Subroutine?
by shenme (Priest) on Aug 07, 2003 at 01:53 UTC
    Didn't notice your mention of the module version until I verified that 3.00 is the version where that line number made sense. The line number for that line is off by two in version 3.02. Strangely enough the two line difference is the addition of
    croak("Could not load my own date parsing: $@") if length($@);
    I'd grab the newer by a year version of the module and see if you get different results, though perhaps that might be getting the error message.

    (Looking at why code in __DATA__ might fail ... do you have module Time::Local installed on your system?)

      I may try the version 3.02, just to keep current. In the meantime, I did discover that a subroutine in Logfile::Base requires Time::ParseDate, which was not installed on my system. I'm on a Win 2000 system and the module wasn't available from ActiveState so I downloaded it from CPAN and installed it. While it failed 92 out of 268 subtests, it still works enough to get through the Logfile date parsing.

      Now I have an error  "No Index for Host".

      Gotta love it. This much trouble for a "simple" 6 line bit of code. Back to debugging.

        Yes, it was looking for any one of several different time modules, including Time::ParseDate, then using its own subroutine, which _still_ required Time::Local.

        I have not been able to get anything other than

        $log->report(Group => 'thing', ... );
        to work, where 'thing' is _one_ of the names mentioned in the new( Group => ). The module seems to handle only one key at a time.   It is more painful than I thought it would be....

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://281619]
Approved by dorko
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2022-05-16 08:24 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (62 votes). Check out past polls.