this is my text file: textfile line1: 1 => A B C D E F G textfile line2: 2 => B F G textfile line3: 3 => D E F textfile line4: 4 => A C textfile line5: 5 => A D E F G textfile line6: 6 => G #### 1 => A B C D E F G 5 => A D E F G #(Since, there are 5 matches in the above array..and the order decreases depending pon the matches) 2 => B F G 3 => D E F 4 => A C 6 => G #### while() { chomp; $_ =~ /(.*)\s+\=\+\s+(.*)/; $number = $1; $values = $2; #I am creating an array here @array = split " ", $2; #here I am creating a reference to the hash**@AOA is now reference to the original @array push @AOA, [@array]; } for $i ( 0 .. $#AOA ) { for $j ( 0 .. $#{ $AOA[$i] } ) { print "## $i $j is $AOA[$i][$j]\n"; } } #### ## 0 0 is A ## 0 1 is B ## 0 2 is C ## 0 3 is D ## 0 4 is E ## 0 5 is F ## 0 6 is G ## 1 0 is A ## 1 1 is D ## 1 2 is E ## 1 3 is F ## 1 4 is G ## 2 0 is B ## 2 1 is F ## 2 2 is G ## 3 0 is D ## 3 1 is E ## 3 2 is F ## 4 0 is A ## 4 1 is C ## 5 0 is G