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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:06:35+00:00 2026-05-12T05:06:35+00:00

I have a output file which is a two dimensional array (this file was

  • 0

I have a output file which is a two dimensional array (this file was output generated after running script written to produce 2D array) and I have to read information under a particular column, say column 1. In other words, how do I read and print out information listed, corresponding to all the rows, under column 1.

Any suggestions?

__DATA__
   1  2  3  4  5  6  7  8  9
   A  B  C  D  E  F  G  H  I
  93  48 57 66 52 74 33 22 91

From the above data I want to extract information column wise, say if I want information from column 1, I should be able to list only the following output.
want to list Then I want

OUTPUT:

1
A
93
  • 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-05-12T05:06:35+00:00Added an answer on May 12, 2026 at 5:06 am

    Final version after all corrections:

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    
    my $column_to_show = 0;
    
    while ( <DATA> ) {
        last unless /\S/;
        print +(split)[$column_to_show], "\n";
    }
    
    __DATA__
       1  2  3  4  5  6  7  8  9
       A  B  C  D  E  F  G  H  I
      93  48 57 66 52 74 33 22 91
    

    Output:

    C:\Temp> u
    1
    A
    93
    

    Explanation of print +(split)[$column_to_show], "\n";:

    perldoc -f split:

    Splits the string EXPR into a list of strings and returns that list.
    …
    If EXPR is omitted, splits the $_ string. If PATTERN is also omitted,
    splits on whitespace (after skipping any leading whitespace).

    So: (split)[3] selects the fourth element of the list returned by split. The + in front of (split) is necessary to help perl parse the expression correctly. See perldoc -f print:

    Also be careful not to follow the
    print keyword with a left parenthesis
    unless you want the corresponding
    right parenthesis to terminate the
    arguments to the print — interpose a +
    or put parentheses around all the
    arguments.

    I thoroughly recommend every Perl programmer to occasionally skim through all of the documentation perldoc perltoc. It is on your computer.

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

Sidebar

Related Questions

I have a file from which I've output several columns of information, 4 to
I have a ruby bash script to download a zip file and output a
I have a file which is space delimited which looks like this: probeset_id submitted_id
I have file which looks like this: >gi|358482566|ref|NW_003766328.1| Gallus gallus breed Red Jungle fowl,
I have an application that generates a lengthy Xml output file which contains many
I have a file app.c which uses two libraries GStreamer and libXml2. To compile
I have a 2 dimensional byte array I[][], each entry in which is either
I have: $page_file_temp = $_SERVER[PHP_SELF]; which will output: /templates/somename/index.php I want to extract from
I have the following code which outputs an object to an XML file: using
I have a windows batch file, which outputs directory path, e.g.: @echo c:\windows I

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.