http://www.perlmonks.org?node_id=1042565


in reply to sorting dates in YYYYMMDD format

Don’t make this harder than it needs to be.   The reason for using a YYYYMMDD format is that it can “just be sorted as-is,” whether numerically or as a string.   Breaking it down into three groups, only to concatenate them in the same order, does nothing at all.   If you need to isolate the string from a bigger string, a simple pattern looking for 8 consecutive digits will do it.