use Date::Manip;
should be
use Date::Manip::Date;
| [reply] [d/l] [select] |
Not necessarily - it works as is here, Date::Manip::Date is brought in by Date::Manip.
| [reply] |
Not necessarily
I stand by what I said. There's no reason to that undocumented feature, especially since it didn't work.
it works as is here,
Apparently not in the version the OP has.
| [reply] |
Actually, this is NOT guaranteed to work.
Date::Manip version 5.xx does not include the Date::Manip::Date module. Date::Manip 6.xx is a complete rewrite which breaks the module into several pieces including Date::Manip::Date for working with dates (and other modules for working with deltas, timezones, etc.). The actual Date::Manip module is just a backwards-compatible wrapper around these modules.
So, if you say:
use Date::Manip;
$obj = new Date::Manip::Date;
and you have Date::Manip 5.xx installed, this code will fail, exactly as described elsewhere in the thread.
As suggested elsewhere in the thread, the proper solution IS to include the line:
use Date::Manip::Date;
in the code.
| [reply] |
If you can, install Date::Manip from CPAN. Otherwise, try a solution with one of the modules you have installed, maybe DateTime. | [reply] |
Date::Manip module is installed.
But when I use the code
#!/usr/bin/perl
use strict;
use warnings;
use Date::Manip;
my $date_manip_object = new Date::Manip;
$date_manip_object->parse( '2 days ago' );
$date_manip_object->convert( 'GMT' );
my $gmt_ref = $date_manip_object->printf( '%Y%m%d') ;
while (<DATA>) {
my $err = $date_manip_object->parse_format('.*?\\[%d/%b/%Y:%T\s+%z
+\\].*', $_);
next if $err; # skip (?) lines that do not match the date format
my $input_line_date = $date_manip_object->printf( '%Y%m%d') ;
if ($input_line_date eq $gmt_ref) {
print;
}
}
__DATA__
10.1.10.178 - - [15/Jun/2010:23:30:34 +0000] -
10.1.10.178 - - [16/Jun/2010:23:30:34 +0000] -
Can't locate object method "new" via package "Date::Manip" at | [reply] [d/l] |
my $date_manip_object = new Date::Manip;
Where in the documentation did you find that usage? It doesn't work because the module does not work that way. Read Date::Manip.
| [reply] [d/l] |