How to convert date to era in Perl?

I don't really like Solaris 10. I am trying to run a simple script to accept the date and return date of this date:

#!/usr/bin/perl -w
use strict;
use Time::ParseDate;

my $date1 = "Mon Mar 27 05:54:08 CDT 2009";

#Convert to seconds since start of epoch
my $time1 = parsedate($date1);
print $time1;

Works great on the RHEL field, but is inserted into Solaris (both have 5.8.8 Perl), which gives the following error message.

Cannot find Date / Parse.pm in @INC (@INC contains: /usr/perl5/5.8.4/lib/sun4-solaris-64int/usr/perl5/5.8.4/lib/usr/perl5/site_perl/5.8. 4 / sun4-solaris-64int / usr / perl5 / site_perl / 5.8.4 / usr / perl5 / site_perl / usr / perl5 / vendor_perl / 5.8.4 / sun4-solaris-64int / usr / perl5 / vendor_perl / 5.8.4 / usr / perl5 / vendor_perl.) On line try1.pl 3. BEGIN failed - compilation is interrupted on line try1.pl 3.

What is wrong here? .. How to fix it?

.. , // - Solaris, script , Solaris 10!. .: (

+3
6

, Date:: Parse Perl (@INC).

CPAN ( Perl). Perl, , ( > 90%) CPAN, Perl.

CPAN ( CPAN CPAN). FAQ 5: " root, ?"

+4

Time:: Piece, Perl 5.10 ( : ​​ 5.8). . . man strftime, man strptime perldoc Time::Piece. Time::Piece " ". ( Solaris. OS X .)

#!/usr/bin/env perl
use strict;
use warnings;
use Time::Piece;

my $date = Time::Piece->strptime("Tue Apr 7 12:46:59 2009",
  "%a %b %e %H:%M:%S %Y");
my $epoch_date = $date->epoch;

print "$epoch_date\n";

. CDT (% Z, , ), . :

my $string = "Mon Mar 27 05:54:08 CDT 2009";
$string =~ s/CDT/-0500/; # Replace timezone with offset from UTC
my $date = Time::Piece->strptime($string, "%a %b %e %H:%M:%S %z %Y");
my $epoch_date = $date->epoch;

print "$epoch_date\n";

CDT = > -0500 CST = > -0600. .

+4

, ? Date::Parse - Time::ParseDate. , .

Module:: CoreList, , 5.8.8. , Solaris 10 - .

, script. (, Perl package.)

+3

, , PAR:: Packer , ( ).

+3

Solaris 10 . script,

, ? , .

0

, . timelocal Time:: Local. . perlfaq 4

0

Source: https://habr.com/ru/post/1706048/


All Articles