Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: GMT to PST format

by Anonymous Monk
on Jun 20, 2010 at 07:08 UTC ( #845595=note: print w/ replies, xml ) Need Help??


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.


Comment on Re^2: GMT to PST format
Download Code
Re^3: GMT to PST format
by ikegami (Pope) on Jun 20, 2010 at 07:25 UTC
      Not necessarily - it works as is here, Date::Manip::Date is brought in by Date::Manip.

        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.

        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.

Re^3: GMT to PST format
by Krambambuli (Deacon) 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://845595]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (13)
As of 2014-12-25 03:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls