in reply to splitting string based on length index

$hash{$1} = substr($data, pos($data)+1, $2) while ($data =~ /(\w+)\[(\ +d+)\]/g);
If keys can contain other values than \w, you might want to change that. Otherwise, this works just fine.