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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:05:53+00:00 2026-06-11T23:05:53+00:00

When combining specific data from a couple of arrayrefs, I mapped the transformation as

  • 0

When combining specific data from a couple of arrayrefs, I mapped the transformation as per the following code:

my @output_data = map {
  my $ss = $everything->{$_->{username}};
  my $distance = $gis->distance ( $_->{lat}, $_->{long} => $ss->{Latitude}, $ss->{Longitude} );
  my %data;
  @data{qw/username addr1 addr2 city state zip rec_lat rec_long/} = @{$_}{qw/username addr1 addr2 city state zip lat long/};
  @data{qw/ss_lat ss_long/} = @{$ss}{qw/Latitude Longitude/};
  $data{difference} = sprintf("%.3f", $distance->miles);
  \%data;
} @$source;

Which works. It builds a hash by adding a couple of slices from the initial data sets (which individually do not comprise the entire row, just what I care about) as well as the result of a calculation between the two. Is there a way that the ending lines can be combined cleanly into a single anonymous hashref constructor? Or would building the resulting dataset like this be the preferred way to go about it?

  • 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-11T23:05:54+00:00Added an answer on June 11, 2026 at 11:05 pm

    You’d need something like pairwise.

    use List::MoreUtils qw( pairwise );
    
    my @output_data =
       map +{
          ( pairwise { $a => $_->{$b} }
             @{[qw( username addr1 addr2 city state zip rec_lat rec_long )]},
             @{[qw( username addr1 addr2 city state zip lat     long     )]},
          ),
          ( pairwise { $a => $ss->{$b} }
             @{[qw( ss_lat   ss_long   )]},
             @{[qw( Latitude Longitude )]},
          ),
       },
          @$source;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a specific method for combining a list of data.tables in R? I
I'm just combining css files from other templates but I can figure out why
Let's say we have the following Haskell: data T = T0 | T1 |
A customer wants their product to require users to enter a machine-specific code, so
I know this is a very specific question. I am compiling a c++ code
I'm having a problem compiling the following code with avr-g++ (C++ compiler for AVR
I'm having some trouble combining these two specific selectors, whereas I don't have the
I had this code from a previous question, but its not compiling: public interface
I am combining div toggling with complex forms: http://railscasts.com/episodes/75-complex-forms-part-3 My specific situation: I have
Is there a specific Xcode compiler flag that gets set when compiling for iPad?

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.