getting the date fields in Perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting getting the date fields in Perl
# 1  
Old 01-31-2005
getting the date fields in Perl

I get the perl date in the following format:

Mon Jan 31 06:01:37 2005

How can I extract each field in a single line using a regular expression??

I dont want to use "split".

Any other way out??

JP Smilie
# 2  
Old 01-31-2005
Why the limitation? Why dont you want to use split?
# 3  
Old 01-31-2005
I'm confused.

perl manuals all document the various Time:: modules. They all return an array which contains all of the fields you show above:
Code:
use Time::localtime;
$lt = localtime();
print $lt->mon;
print $lt->mday;
print $lt->year;

Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sorting on fields for last date

Hi all, I have a file with a list of rpm's that have different dates. I am trying to just grab the latest rpm and install date, and discard the rest. The file has 1000's of entries all with different names and dates. I have tried sort -k on the file and I am not grabbing the info, ... (4 Replies)
Discussion started by: gartie
4 Replies

2. UNIX for Advanced & Expert Users

Sort in fields date and columns.

Hi colleagues, I have this output, i need sort for 7th and 8th columns, the column 7th is date mm/dd/yyyy format and column 8th is time hh:mm:ss.number PRUEBA 1263 0007 1 0 7131292 03/25/2013 16:43:04.159976 PROCESS PRUEBA1 666 0146 1 0 11600064 ... (1 Reply)
Discussion started by: systemoper
1 Replies

3. Shell Programming and Scripting

Fetch date of 7 years back from current date in Perl

$beginDate = substr(DateCalc("today", "-7Days"),0,8); This fetches the date 7 days back Can I fetch the date before 7 years from todays date in Perl using same syntax Use code tags, see PM. (3 Replies)
Discussion started by: parthmittal2007
3 Replies

4. Shell Programming and Scripting

Need to capture dates between start date and end date Using perl.

Hi All, Want to get all dates and Julian week number for that date between the start date and end date. How can I achive this using perl? (To achive above functionality, I was connecting to the database from DB server. Need to execute the same script in application server, since databse... (6 Replies)
Discussion started by: Nagaraja Akkiva
6 Replies

5. Shell Programming and Scripting

How to remove '-' for date fields alone in a file

Hi, I have a scenario like, I need to replace a hyphens(-) for date field alone in the file. I have minus(-) sign for other fields it should remain as such, only for date fields hyphens must be removed. Please find the content for the file below: sample.txt: -----------... (4 Replies)
Discussion started by: G.K.K
4 Replies

6. Shell Programming and Scripting

Perl: Extracting date from file name and comparing with current date

I need to extract the date part from the file name (20080221 in this ex) and compare it with the current date and delete it, if it is a past date. $file = exp_ABCD4_T-2584780_upto_20080221.dmp.Z really appreciate any help. thanks mkneni (4 Replies)
Discussion started by: MKNENI
4 Replies

7. Shell Programming and Scripting

Stripping date fields

How would I strip a date field? For example, if I have TODAY defined as the following: TODAY=`date +"%m/%d/%y"`, TODAY is assigned the value 11/01/03 on Nov 1, 2003 How would I strip the first 2 bytes? (11)? Thank you in advance for the help. (6 Replies)
Discussion started by: Latha Nair
6 Replies
Login or Register to Ask a Question