Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9238527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:47:03+00:00 2026-06-18T07:47:03+00:00

my %Hash= (2012=> 1, 1982=>12, 2010=>0); The has key and values need to be

  • 0
my %Hash= (2012=> 1, 1982=>12, 2010=>0);

The has key and values need to be all on the same field name ‘time’ like an array

$mycollection->insert(
                     {
                         'field1' => $var1;
                         'field2' => $var2;
                          #right here I need to know how to add above hash key and values
                          # like below  
                          #'time': ["2012.1","1982.12","2010.0"]   
                     }
                   );

Any suggestions or ideas will be apprecieated. This can probably accomplished by doing series of update statements but I would like to accomplish this with one insert statement due to my requirement.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:47:04+00:00Added an answer on June 18, 2026 at 7:47 am

    I suppose your %Hash variable is something like this:

    my %Hash= (2012=> 1, 1982=>12, 2010=>0);
    

    So your array “time” is build this way:

    my @time = map { $_ . "." . $Hash{$_} } keys %Hash;
    

    and finally:

    $mycollection->insert({
       'field1' => $var1,
       'field2' => $var2,
       'time' => \@time   
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why two object's hash code is not same even though they have similar values.
Hash.each returns an array [key, value] , but if I want a hash? Example:
I have (anonymized) a hash constructed from values in Python 2.6.8: sys.stderr.write('#' + str(dictionary['Field
I would like to make a sort of hash key out of a text
My Hash Table implementation has a function to resize the table when the load
anything slider is adding hash tags like #&panel1-1 at the end of the url.
I have a hash that looks like this h1 = {4c09a0da6071a593f051de32=>[4c09a0da6071a593f051de32, Cafe Bistro, 37.78458803130115,
All right, I'm not doing something right, and I need some help. Here's what's
I need to connect to a web service that has wsse security and need
2 hash: h1 = { s1 => 2009-7-27, s2 => 2010-3-6, s3 => 2009-7-27

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.