Instead of: --1-News1--> This is option News 1 of 1 ?--1-News1--> --3-Third1of3--> Option Third 1 of 3 ?--3-Third1of3--> what about: 1,News,1,1 3,Third,1,3 Then you can do something like: ($num, $name, $index, $total) = split /,/, $data;