in reply to How can i read the lines and store them in an array like following fashion?

If the file is not too big, slurp it into $_ and do a global regex match to get each "ITEM" and attendant lines which you can then split on newline. Like this

use strict; use warnings; use Data::Dumper; { local $/; $_ = <DATA>; } my $raDataItems = [ map {[split m{\n}]} m{(ITEM.*?)(?=(?:\z|ITEM))}sg ]; my $dd = Data::Dumper->new([$raDataItems], [q{raDataItems}]); print $dd->Dumpxs(); __END__ ITEM NO:1 [aaa] 111 [bbb] 222 [ccc] 333 ITEM NO:2 [ddd] 444 [eee] 555 [fff] 666 ITEM NO:3 [ggg] 777 [hhh] 888 [iii] 999

and the output is

$raDataItems = [ [ 'ITEM NO:1', '[aaa]', '111', '[bbb]', '222', '[ccc]', '333' ], [ 'ITEM NO:2', '[ddd]', '444', '[eee]', '555', '[fff]', '666' ], [ 'ITEM NO:3', '[ggg]', '777', '[hhh]', '888', '[iii]', '999' ] ];

I hope this is of use.

Cheers,

JohnGG