use strict; use warnings; my $hash_of_excel = [ { col1 => "value1", col2 => "value2", col3 => "value3|value4", col4 => "value5|value6|value7", }, { col1 => "value8", col2 => "value9", col3 => "value10|value11|value12", col4 => "value13|value14|value15", }, { col1 => "value16|value17", col2 => "value19|value18", col3 => "value20", col4 => "value21", } ]; foreach my $results (@$hash_of_excel){ my $glob_expression; for my $colname( sort keys %$results){ my @array = split /\|/,$results->{$colname}; $glob_expression .= '{' . join(',', @array) . '};'; } chop $glob_expression; print "EXP: $glob_expression:\n"; print "\t", join("\n\t", glob $glob_expression), "\n\n"; }