You do have delimiters there (of a sort)
2Jul2001
^^ ^
Number Letter Number
@dates = qw(2Jul2001 21Jul2001);
foreach (@dates) {
/(\d+)(\D+)(\d+)/;
$day = $1;
$month = $2;
$year = $3;
print "Day $day, month $month, year $year\n";
}
John
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 03 July 2001 12:24
To: [EMAIL PROTECTED]
Subject: A Split Question
Hi.
My file has dates in it that either come out as "2Jul2001" or "21Jul2001".
So one or two digits for the day, three for the month, and four for the
year.
So I would like to split out the day, month, year, and am interested in
splitting techniques, where there are no delimeters.
Of course, I could just test the length and then use substr it all out, or
even sprintf it into a new variable with a pad at the first character.
But this is perl, and I reckon there are much cooler ways to do it.
Any takers?
Paul.
------------------------------------------------
Global WebMail -
Delivered by Global Internet www.global.net.uk
------------------------------------------------
--------------------------Confidentiality--------------------------.
This E-mail is confidential. It should not be read, copied, disclosed or
used by any person other than the intended recipient. Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful. If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.