in reply to remove chars with regex
my ($start, $end) = $char =~ /^(\S{6}).*(\S{6})$/; [download]
Note that it's six characters, not five. Also, don't forget to check the length of the string, as shorter strings won't match at all.