Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

perl code

Posted on 2004-08-25
5
Medium Priority
?
156 Views
Last Modified: 2010-03-05
hi..
i have this statment in the perl script that allows me to extract the date "02/31/04"
and insert it to the database in the form of "2004/02/31"
this is the statment :
  if( /Start Date\s*:\s*(\S+)/ ) {
    $job = $1;
    ($date = $2) =~ s!(\d\d)/(\d\d)/(\d\d)!20$3/$1/$2!;

however, the date formate given  is in this form "thur jul 22 10:10:18 2004"
how do i modify the above statment to extract onlt "jul 22 2004"

thanks.
0
Comment
Question by:TPoly
  • 3
  • 2
5 Comments
 
LVL 85

Expert Comment

by:ozo
ID: 11899752
s/\w+\s+(\w+)\s+(\d+)\s+\d\d:\d\d:\d\d\s+(\d\d\d\d)/$1 $2 $3/;
0
 

Author Comment

by:TPoly
ID: 11899822
hi ozo,
 i tried the statement you have provided but it only extract "thur" and
insert it into the database.
0
 

Author Comment

by:TPoly
ID: 11899839
sorry..
my mistake i want to modify the above perl statement from
"thur jul 22 10:10:18 2004" to "2004/07/22"
0
 
LVL 85

Accepted Solution

by:
ozo earned 600 total points
ID: 11899893
$_="thur jul 22 10:10:18 2004";
@m{qw(jan feb mar apr may jun jul aug sep oct nov dec)}=('01'..'12');
 s!\w+\s+(\w+)\s+(\d+)\s+\d\d:\d\d:\d\d\s+(\d\d\d\d)!$3/$m{$1}/$2!;
print;
0
 

Author Comment

by:TPoly
ID: 11900059
hi ozo. the state ment work,
however it is unable to insert the date into the database and
also i have have duplicate dates but i have many text files
with different date.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question