Hi , I have a hash with values as an array.
{'col1'=>[1], 'col2'=>[1,2],'col3'=>[3,4,5]}
And I have to insert the data from this hash to a database table.
So I can't access the values from the traditional foreach loop since this would result in multiple entries depending on the number of keys.
So I would like to get a way where I can access the multiple values without looping.
foreach my $results(@$hash_of_excel){
my $specificresults = GroupResults($results);
insertResult($specificresults->{'Desc'});
#last if $counter++ == 2;
}
sub GroupResults{
my( $AllRecords )= @_;
my %specificResults;
for my $info (keys %details){
$specificResults{$info}{$_} = $AllRecords->{$_} for @{$details{$in
+fo};
}
}
return \%specificResults;
}
sub SomethingUnPipeModifyRecord {
my( $rec ) = @_;
for my $val( values %$rec ){
my $newval = [ split /\|/, $val ];
$val = $newval;
}
return $rec;
}
sub insertL{
my ($li_results )= @_;
my $liarray_values = SomethingUnPipeModifyRecord($ligand_results);
#warn Dumper($li_array_values);
warn "insert into LI values $li_array_values->{'Code'}[0],$li_array_v
+alues->{'US'}[0],$li_array_values->{'IN'}[0],$li_array_values->{'STEM
+'}[0]";
#my $ligand_insert = "insert into LI
values(LI_SEQ.nextval,'SM',?,?,?,?,?,?,1,sysdate,?)";
}
I can access the first value but not the subsequent values Is there any smart way of doing this? Thanks a ton.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.