#!/usr/bin/perl use 5.016; use warnings; use Data::Dumper; =head vitoco's msg: vitoco says Re Re^2: Move data into AoH The data file happens to be a JSON structure, an array of records, very like an AoH. I know how to manage them in perl, but as text values may have the special chars inside, there was no simple regexpr to parse that. =cut # 1055528 my @arr; my $recsep = q(,); while ( ) { @arr = split /$recsep/, $_; } my $i=1; for my $record(@arr) { say "\t $i: $record \n"; ++$i; } say "\n\n"; say Dumper @arr; =head vitoco: There are no newlines (I put them to show records), ww: So here's data with extra newlines removed but with (from OP) some regex-special characters... namely, the square brackets... which vitoco says prevent writing a "simple regexpr" -- OK, this uses split and a regular expression (without any post-5.8 bells and whistles), but the outcome isn't changed. =cut __DATA__ [{field1:value1,field2:value2,field3:value3},{field1:value4,field2:value5,field3:value6},{field1:value7,field2:value8,field3:value9}]