in reply to Re^2: Extract data and store to db
in thread Extract data and store to db

> Both

second one, best do it in a loop.

first one

use v5.12; use warnings; use Data::Dump qw/pp dd/; my @AoH; my $count = 0; while (<DATA>) { chomp; if ( /---START---/ .. /---END---/) { if ( /\|([A-Z]+): (.+)/) { $AoH[$count]{$1}=$2; } $count++ if /---END---/; } } pp \@AoH; __DATA__ ---START---- |FULLNAME: JANE DEO |BINF : 492BBJJ |PRICE: 10 |COUNTRY: GR ---END--- ---START---- |FULLNAME: JOHN DEO |BINF : K92BBJJ |PRICE: 24 |COUNTRY: AS ---END---

OUTPUT:
[ { COUNTRY => "GR", FULLNAME => "JANE DEO", PRICE => 10 }, { COUNTRY => "AS", FULLNAME => "JOHN DEO", PRICE => 24 }, ]

Cheers Rolf
(addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
Wikisyntax for the Monastery