Easier way to split a string

Hi
I have got a date in the format "yyyymmdd".
I would like a one liner in PERL that can split the above string into $y,$m and $d.

For example,
if $year is "19810203", then i want a PERL one liner that can split this into 3 parts storing into 3 variables.
That is the 3 variables $y,$m and $d should have "1981","10" and "03" respectively.

Thanks
Vinodh
vinny_r78Asked:
Who is Participating?
 
DeanHorakCommented:
Or in your example

 ($y, $m, $d) = (substr($year,0,4),substr($year,4,2),substr($year,6,2));
0
 
DeanHorakCommented:
($y, $m, $d) = (substr($teststr,0,4),substr($teststr,4,2),substr($teststr,6,2));
0
 
vinny_r78Author Commented:
Thanks DeanHorak.
It is working.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.