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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:24:47+00:00 2026-06-11T06:24:47+00:00

Say I build the following multidimensional array: my @array; # don’t need the empty

  • 0

Say I build the following multidimensional array:

my @array;  # don't need the empty list
my @other_array = (0 ... 10);

foreach my $i ( 0 .. 10 ) {
$array[$i] = [ @other_array[1..$#other_array] ];
}

I would like to collect a “column” of this multidimensional array into a separate array,

For example, if I want to collect the items in the first column, I would like something like

my @other_array = ();
@other_array = $array[:][1]; # This does NOT work in Perl

Is there a way to do this in Perl without looping?

Eventually what I want to do is get the array of max of each column of my multidimensional array.

PS: This question is inspired by this other question: Building and printing a multidimensional list in Perl without looping.

  • 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-11T06:24:48+00:00Added an answer on June 11, 2026 at 6:24 am

    I think you want:

    my @other_array = map { $_->[1] } @array;
    

    Another language might have a special syntax for this operation, but it would still be performing a loop under the hood.

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

Sidebar

Related Questions

I am trying to build JSON from two fields. Say, I have a list
Say I have the following for each in a stripes layout definition <c:foreach items=${foo}
I have build a game using canvas and Javascript, and I would like to
Let's say I build an application on top of net.aserve and bordeaux-threads . My
Is there any Graph Builder for GStreamer? So to say you build graph you
Is there a keyboard shortcut that allows you to easily change Build Configuration (say,
Say I have a build machine and test machine and the source code is
Say I am required to build an E-Commerce website that could eventually become very
Let's say I want to build a REST service for making notes that looks
I am trying to build a Quadtree data structure(or let's just say a tree)

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.