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
In reply to Re^3: Extract data and store to db
by LanX
in thread Extract data and store to db
by frank1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |