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 8034883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:09:04+00:00 2026-06-05T02:09:04+00:00

A variation of this code passed by today (written by a perl coder), and

  • 0

A variation of this code passed by today (written by a perl coder), and it is confusing:

   my $k = {3,5,6,8};
   my $y = {%$k};

Why? What does that do? That seems to be the same thing as this:

   my $y = $k;

The context is in a call using dbi module:

               while (my $x = $db->fetchrow_hashref )
               {  $y{something} = {%$x};  }
  • 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-05T02:09:06+00:00Added an answer on June 5, 2026 at 2:09 am

    The difference is that it’s cloning the data structure without referencing the same memory.

    For example:

    use strict;
    use warnings;
    use Data::Dumper;
    
    my $h={'a'=>1,'b'=>2};
    my $exact_copy=$h; #$exact_copy references the same memory as $h
    $h->{b}++; #$h maps b to 3
    
    print Dumper($exact_copy) . "\n"; #a=>1,b=>3
    
    my $clone={%$h}; #We dereference $h and then make a new reference
    $h->{a}++; #h now maps a to 2
    
    print Dumper($clone) . "\n"; #a=>1,b=>3 so this clone doesn't shadow $h
    

    Incidentally, manually initialising a hash by using all commas (as in my $k = {3,5,6,8}) is very, very ugly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, While this is similar to another post , that post (does not indicate
I've just come across some code that's confusing me slightly; there are really 2
I have code that gets called whenever the form is submitted, this then validates
I want to change this code sample so that all these conditions are evaluated
I coded, global mini form validation for jquery. This here; This code, All form
I've got this piece of code in my jquery validation script: resetForm: function() {
I I want to implement input filed validation. This is the code of the
This is a slightly original variation on a common problem. I have a fairly
As mentioned in this Meta Question , Facebook accepts the exact opposite case variation
this works .. $(select[title='First Choice'] option[text='hello']).remove(); A number of variations of this does not

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.