in reply to splitting a string into arbitrary lengths

unpack

my ($tyear, $tmon, $tday) = unpack( 'A4A2A2', '20050622' );

If you choose to use this, you might also want to read pack and perlpacktut