Sponsored Content
Full Discussion: Perl help
Top Forums Shell Programming and Scripting Perl help Post 302334539 by mohan705 on Thursday 16th of July 2009 05:30:49 AM
Old 07-16-2009
Hi

I am transalting 10/07/2009 to epoch time ,but its giving different results.Please any help on this
Code:
perl -e 'use Time::Local; print timelocal("00","00","00","10","07","2009"),"\n";' 

1249833600

perl -le 'print scalar localtime 1249833600'
Mon Aug 10 00:00:00 2009

Thanks ,
MR
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Perl] Accessing array elements within a sed command in Perl script

I am trying to use a script to replace the header of each file, whose filename are stored within the array $test, using the sed command within a Perl script as follows: $count = 0; while ( $count < $#test ) { `sed -e 's/BIOGRF 321/BIOGRF 332/g' ${test} > 0`; `cat 0 >... (2 Replies)
Discussion started by: userix
2 Replies

2. Shell Programming and Scripting

Passing date formats in Perl: i.e. Jul/10/2007 -> 20070710 (yyyymmdd) - Perl

Hi , This script working for fine if pass script-name.sh Jul/10/2007 ,I want to pass 20070710(yyyymmdd) .Please any help it should be appereciated. use Time::Local; my $d = $ARGV; my $t = $ARGV; my $m = ""; @d = split /\//, $d; @t = split /:/, $t; if ( $d eq "Jan" ) { $m = 0 }... (7 Replies)
Discussion started by: akil
7 Replies

3. Shell Programming and Scripting

perl/unix: script in command line works but not in perl

so in unix this command works works and shows me a list of directories find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt but when i try running a perl script to run this command my $query = 'find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt';... (2 Replies)
Discussion started by: kpddong
2 Replies

4. Shell Programming and Scripting

Perl :How to print the o/p of a Perl script on console and redirecting same in log file @ same time.

How can i print the output of a perl script on a unix console and redirect the same in a log file under same directory simultaneously ? Like in Shell script, we use tee, is there anything in Perl or any other option ? (2 Replies)
Discussion started by: butterfly20
2 Replies

5. Shell Programming and Scripting

Hidden Characters in Regular Expression Matching Perl - Perl Newbie

I am completely new to perl programming. My father is helping me learn said programming language. However, I am stuck on one of the assignments he has given me, and I can't find very much help with it via google, either because I have a tiny attention span, or because I can be very very dense. ... (4 Replies)
Discussion started by: kittyluva2
4 Replies

6. Shell Programming and Scripting

HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

Hi all, Not sure if this should be in the programming forum, but I believe it will get more response under the Shell Programming and Scripting FORUM. Am trying to write a customized df script in Perl and need some help with regards to using arrays and file handlers. At the moment am... (3 Replies)
Discussion started by: newbie_01
3 Replies

7. UNIX for Advanced & Expert Users

perl and HP-UX : instmodsh in combination with software depot : update inventory for installed Perl

we create a HP-UX software depot with a new perl-modul. after installation of the software depot, the perl module i can't find with instmodsh in the inventory for installed Perl modules. - i have learned of using instmodsh command : i find out what modules are already installed on my system. ... (0 Replies)
Discussion started by: bora99
0 Replies

8. Shell Programming and Scripting

Perl :: reading values from Data Dumper reference in Perl

Hi all, I have written a perl code and stored the data into Data structure using Data::Dumper module. But not sure how to retreive the data from the Data::Dumper. Eg. Based on the key value( Here CRYPTO-6-IKMP_MODE_FAILURE I should be able to access the internal hash elements(keys) ... (1 Reply)
Discussion started by: scriptscript
1 Replies

9. Programming

Perl: restrict perl from automaticaly creating a hash branches on check

My issue is that the perl script (as I have done it so far) created empty branches when I try to check some branches on existence. I am using multydimentional hashes: found it as the best way for information that I need to handle. Saing multidimentional I means hash of hashes ... So, I have ... (2 Replies)
Discussion started by: alex_5161
2 Replies

10. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies
DateTime::Format::Epoch(3pm)				User Contributed Perl Documentation			      DateTime::Format::Epoch(3pm)

NAME
DateTime::Format::Epoch - Convert DateTimes to/from epoch seconds SYNOPSIS
use DateTime::Format::Epoch; my $dt = DateTime->new( year => 1970, month => 1, day => 1 ); my $formatter = DateTime::Format::Epoch->new( epoch => $dt, unit => 'seconds', type => 'int', # or 'float', 'bigint' skip_leap_secondss => 1, start_at => 0, local_epoch => undef, ); my $dt2 = $formatter->parse_datetime( 1051488000 ); # 2003-04-28T00:00:00 $formatter->format_datetime($dt2); # 1051488000 DESCRIPTION
This module can convert a DateTime object (or any object that can be converted to a DateTime object) to the number of seconds since a given epoch. It can also do the reverse. METHODS
o new( ... ) Constructor of the formatter/parser object. It can take the following parameters: "epoch", "unit", "type", "skip_leap_seconds", "start_at", "local_epoch" and "dhms". The epoch parameter is the only required parameter. It should be a DateTime object (or at least, it has to be convertible to a DateTime object). This datetime is the starting point of the day count, and is usually numbered 0. If you want to start at a different value, you can use the start_at parameter. The unit parameter can be "seconds", "milliseconds, "microseconds" or "nanoseconds". The default is "seconds". If you need any other unit, you must specify the number of units per second. If you specify a number of units per second below 1, the unit will be longer than a second. In this way, you can count days: unit => 1/86_400. The type parameter specifies the type of the return value. It can be "int" (returns integer value), "float" (returns floating point value), or "bigint" (returns Math::BigInt value). The default is either "int" (if the unit is "seconds"), or "bigint" (if the unit is nanoseconds). The default behaviour of this module is to skip leap seconds. This is what (most versions of?) UNIX do. If you want to include leap seconds, set skip_leap_seconds to false. Some operating systems use an epoch defined in the local timezone of the computer. If you want to use such an epoch in this module, you have two options. The first is to submit a DateTime object with the appropriate timezone. The second option is to set the local_epoch parameter to a true value. In this case, you should submit an epoch with a floating timezone. The exact epoch used in "format_datetime" will then depend on the timezone of the object you pass to "format_datetime". Most often, the time since an epoch is given in seconds. In some circumstances however it is expressed as a number of days, hours, minutes and seconds. This is done by NASA, for the so called Mission Elapsed Time. For example, 2/03:45:18 MET means it has been 2 days, 3 hours, 45 minutes, and 18 seconds since liftoff. If you set the dhms parameter to true, format_datetime returns a four element list, containing the number of days, hours, minutes and seconds, and parse_datetime accepts the same four element list. o format_datetime($datetime) Given a DateTime object, this method returns the number of seconds since the epoch. o parse_datetime($secs) Given a number of seconds, this method returns the corresponding DateTime object. BUGS
I think there's a problem when you define a count that does not skip leap seconds, and uses the local timezone. Don't do that. SUPPORT
Support for this module is provided via the datetime@perl.org email list. See http://lists.perl.org/ for more details. AUTHOR
Eugene van der Pijll <pijll@gmx.net> COPYRIGHT
Copyright (c) 2003-2006 Eugene van der Pijll. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
DateTime datetime@perl.org mailing list perl v5.10.1 2007-12-03 DateTime::Format::Epoch(3pm)
All times are GMT -4. The time now is 03:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy