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

  • Home
  • SEARCH
  • 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 8592957
In Process

The Archive Base Latest Questions

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

I want to make an array in Perl with the values obtained from my

  • 0

I want to make an array in Perl with the values obtained from my awk script. Then I can do math on them in Perl.

Here is my Perl, which runs a program, which saves a text file:

my $unix_command_dsc = (`./program -s test.fasta saved_file.txt`);
my $dsc_run = qx($unix_command_dsc);

Now I have some Awk that parses that data saved in the text file:

#!/usr/bin/awk -f

BEGIN{       # Initialize the values to zero. Note, done automatically also.
    sumc4 = 0
    sumc5 = 0
    sumc6 = 0
}

/^[1-9][0-9]* residue/ {next}    #Match line that begins with number and has word 'residue', skip it.
/^[1-9]/ {                       #Match line that begins with number.

    sumc4 += $4                  #Add up the values of the nth column into the variables.
    sumc5 += $5
    sumc6 += $6

    print $4 "\t" $5 "\t" $6    #This will show the whole columns. 

    }

END{
    print "sum H" "\t" "sum E" "\t" "sum C"
    print sumc4 "\t" sumc5 "\t" sumc6  
}

I run this Awk from terminal with the following commands:

./awk_program.txt saved_file.txt 

Any ideas how I would gather this data from the print statements in awk into arrays in perl?

What I’ve tried is to just run that awk script in perl:

my $unix_command_awk = (`./awk_program.txt saved_file.txt`);
my $awk_run = qx($unix_command_awk);

But perl gives me errors and commands not found, like it thinks the data are commands. Should there be a STDOUT in the awk that I’m missing, rather than print?

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

    It should just be:

    my $awk_run = `./awk_program.txt saved_file.txt`;
    

    Backticks tell perl to run the command and return the output. So your assignment to $unix_command_awk is running the command, and then qx($unix_command_awk) executes the output as a new command.

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

Sidebar

Related Questions

i want to find values in array according to alphabate and want to make
I want to make an array in Prolog. How can do it? How can
If you want to make an array of integers, can you use NSInteger? Do
I want to make an array with a random amount of values between 2
I want to make a multidimensional array in php. Here is what i have
In my app i want to make array, add to toolbar and then release
I want to make an array sort method so you can sort some info
I have the following values: $attached_products = 1,4,3; I want to make an array
I want to make a json array in Servlet from a result set. If
I have an array, and I want to make a hash so I can

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.