Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing specific characters in a scalar 1

Status
Not open for further replies.

twitaboy

Programmer
Feb 25, 2003
14
0
0
AU
Hey Tek-Tips,
I have a database full of dates in the form of year/month/day/time/second in a string of characters.

Eg. 20030102030405 is 2003, January the second, at 3.04.05 am.

I am attempting to parse the dates in the format they are in, back into separate variables.

Eg.
$year = "2003";
$month = "01";
$day = "02";

I figured I could do something like this:
$year = $rawdate[01];

but that doesn't work.

Any ideas, tips, or code, would be very greatly appreciated.

Thanks,
twitaboy
 
Do something like this:

Code:
$date = " 20030102030405"

my ($year,$month,$day) = $date =~ /(....)(..)(..)/;


 
Thanks heaps raklet, 100% correct and helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top