use strict; use warnings; use Data::Dumper; my $str = "{file => 'file1', desc => 'test'}, {file => 'file12', desc => 'test2'}" my $string = $str; my @array_of_hashes; my @array_of_hashes; my @hashes = $string =~ /(\{.*?\})/g; for my $hashstr (@hashes) { my @keys = $hashstr =~ /(\w+)\s*=>/g; my @values = $hashstr =~ /=>\s*\'(\w+)\'/g; my %hash; @hash{@keys} = @values; push @array_of_hashes, \%hash; } print "Pragma: no-cache\n"; print "Content-type:text/html\n\n"; print Dumper(\@array_of_hashes);