#!/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}] #### C:\>perl D:\_Perl_\PMonks\1055528.pl 1: [{field1:value1 2: field2:value2 3: field3:value3} 4: {field1:value4 5: field2:value5 6: field3:value6} 7: {field1:value7 8: field2:value8 9: field3:value9}] $VAR1 = '[{field1:value1'; $VAR2 = 'field2:value2'; $VAR3 = 'field3:value3}'; $VAR4 = '{field1:value4'; $VAR5 = 'field2:value5'; $VAR6 = 'field3:value6}'; $VAR7 = '{field1:value7'; $VAR8 = 'field2:value8'; $VAR9 = 'field3:value9}]';