in reply to logical solution for a array of hash

I don't understand what you want to do, does this help? Does it inspire a new question?
#!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd /; my $record = { col1 => "value8", col2 => "value9", col3 => "value10|value11|value12", col4 => "value13|value14|value15", }; dd( $record ); SomethingUnPipeModifyRecord( $record ); dd( $record ); dd( $record->{col4} ); dd( $record->{col4}[0] ); sub SomethingUnPipeModifyRecord { my( $rec ) = @_; for my $val( values %$rec ){ my $newval = [ split /\|/, $val ]; $val = $newval; } return $rec; } __END__ { col1 => "value8", col2 => "value9", col3 => "value10|value11|value12", col4 => "value13|value14|value15", } { col1 => ["value8"], col2 => ["value9"], col3 => ["value10", "value11", "value12"], col4 => ["value13", "value14", "value15"], } ["value13", "value14", "value15"] "value13"

Replies are listed 'Best First'.
Re^2: logical solution for a array of hash
by spie287 (Novice) on Feb 13, 2015 at 14:39 UTC

    That's right but my question was how would I know whether the particular record has more than one values or not without looping through them?

    For example the col3 has more values but col2 has on value. I would like to skip the col2 from going through any loop if it has one value and proceed with the insert statements. If I have more than one values then I have to loop through them for each value to be inserted to the DB. Hope I am clearer this time.