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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:55:16+00:00 2026-06-09T12:55:16+00:00

#!/usr/bin/perl my $file = $ARGV[0]; my $value = $ARGV[1]; my @grabbed; open (FILE, $file);

  • 0
#!/usr/bin/perl

my $file = $ARGV[0];
my $value = $ARGV[1];

my @grabbed;

open (FILE, $file);

while (<FILE>) {
    if (/alignment#  residue#/) {
            push @grabbed, $_;
            while (<FILE>) {
            last if /^$/;
            push @grabbed, $_;
            }
    }
}
close (FILE);


my $line= `awk '  {if(\$2==$value)} ' @grabbed`;

print $line;

Problem :

1.First, I don’t know if its possible to do awk on an array or not?
2. I am trying to match a value, existing on the second column of the 2-D array (@grabbed). The @grabbed will look like this :

     7         1         M     1.000         6                .VPMLG     66.63
     8         2         S     1.000        10            .QINTSARKG     66.63
     9         3         V     1.000        13         .KTAVFPRGQMSL     66.63
    10         4         L     1.000         7               .SLAKFT     66.63
    11         5         L     1.000        14        .ALSVQWIKMRYPF     66.63
    12         6         R     1.000        16      .DERSAVGTNQLYMIP     66.63
    13         7         S     1.000        18    .GDTHPKRSALFCIQVYN     66.63
    14         8         G     1.000        17     .DRFLENGAQPSTYCHM     66.63
    15         9         L     1.000        19   .NDHPELASVKRCWFGTQI     66.63
    16        10         G     1.000        18    .RLDPEGFTYAVCIKNMH     66.63

I am trying to match and grab the line in which column 2 is of value “9”.

  • 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-09T12:55:18+00:00Added an answer on June 9, 2026 at 12:55 pm

    No need to swith to awk when that job can be done with perl too.

    for ( @grabbed ) {
        my @f = split;
        if ( $f[1] == $value ) {
            push @line, $_;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with the following code (Perl/Cygwin) #!/usr/bin/perl open FILE, >, filename.txt
#!/usr/bin/perl use File::Copy; use File::Copy::Recursive; $old_folder=$ARGV[0]; $new_folder=$ARGV[1]; $folder_loc=$ARGV[2]; print Content-type:folder rename\n\n; #rename($arg1,$arg2) || print
#!/usr/bin/perl -w use strict; open (EVENTLOGFILE, <eventlog.txt) || die(Could not open file eventlog file);
I have the following code #!/usr/bin/perl use Tie::File; tie my @last_id, 'Tie::File', 'last_id.txt' or
This is my first Perl script. Ever: #!/usr/bin/perl if ($#ARGV < 1) { die(usage:
I have this script: #!/usr/bin/perl $LOGFILE = Soccer.txt; open(LOGFILE) or die(Could not open log
#!/usr/bin/perl -w use strict; use File::Copy; use File::Spec; my($chptr, $base_path, $new, $dir); $dir =
I have the following file: #!/usr/bin/perl use Test::Unit::TestCase; $self->assert(1) and when I run test.pl
I have a perl.cgi file which has the content: #!/usr/bin/perl print Content-type: text/html\n\n; print
Perl question for you: #!/usr/bin/perl use File::Find; #Find files find(\&wanted, $dir); sub wanted {

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.