in reply to Re: GMT to PST format
in thread GMT to PST format

Unfortunately we don't have installed this module.
Can't locate object method "new" via package "Date::Manip::Date" (perh +aps you forgot to load "Date::Manip::Date"?)
I am getting the error as above. Please tell me is there any other way to do this.

Replies are listed 'Best First'.
Re^3: GMT to PST format
by ikegami (Patriarch) on Jun 20, 2010 at 07:25 UTC
      Not necessarily - it works as is here, Date::Manip::Date is brought in by Date::Manip.

        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.

        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.

Re^3: GMT to PST format
by Krambambuli (Curate) on Jun 20, 2010 at 08:10 UTC
    If you can, install Date::Manip from CPAN. Otherwise, try a solution with one of the modules you have installed, maybe DateTime.
      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
        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.