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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:33:36+00:00 2026-06-09T22:33:36+00:00

I’ve been struggling with this for a while and I was wondering if there

  • 0

I’ve been struggling with this for a while and I was wondering if there was something obvious I’ve missed.

As programming learning/practice, I’m trying to put together a simple script for calculating the components of a restriction enzyme digest mix. However, first I need to get a list of enzyme stock concentrations.

I pulled all the individual pages from the New England Biolabs enzyme page, and my goal with this current script is to pull out the name of the enzyme and the concentrations available from the company.

This example works with a local copy of EcoRI (link included at bottom of submission).

use warnings;
use strict;
open(FILE,'productR0101.asp');
my $line;
my $counter;
my $array1;
my $array2;
my $array3;
my $concentration;
my @array4;
$counter = 1;

while ($line = <FILE>) {
    chomp($line);

    if ($counter == 6 ){
        $array1 = $line;
        $counter++;
    }
    else{
        $counter++;
    }

    if ($line =~ m/.{8}units.ml/g) {
        (@array4) =$line =~ m/.{8}units.ml/g;
        print @array4;
    }
}
print "\n".$array1;
exit;

Every file has the enzyme name on the sixth line of the file, so I just pulled that whole line. However, the concentrations are in different locations, so my approach was to read in the file one line at a time, and match to the units/ml tag.

My thinking was that it should print out the match for each line, if there was one, every time the while loop runs, effectively resulting in a string of separate print statements.

This is where I get messed up. There are six different locations in this file with a units/ml tag: three for 20,000 and three for 100,000.

I was expecting six different results printed, but when I run this, only one 100,000 units/ml result is returned.

I’ve tried all sorts of fixes. I tried concatenating strings, I tried storing it as a string, I tried concatenating it onto another array that never gets touched by the (@array4) = $line =~ m/.{8}units.ml/g line, and it either breaks it or gives the same result.

And finally, I apologize for any weird conventions. I’m still learning Perl, and my first experience programming was with MATLAB.

Also, the $array1, $array2, etc. exist because I was trying to keep track of exactly what was getting put where; my intention is to clean it up once I get it functional.

So does anyone have any ideas about what I’m doing wrong?

EDIT: the data source is the source code to each individual enzyme page. For this example, if you view the page source you get the complete input file I gave to the script.

  • 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-09T22:33:38+00:00Added an answer on June 9, 2026 at 10:33 pm

    We really need to see the data you are processing, but it looks like you are storing only the last occurrence of /units.ml/ in @array4 because you are reading the file line by line.

    I will add to this answer if you supplement your question, but for now I need to know

    • What your data looks like

    • What the mysterious /.{8}/ is for

    • Are you aware that $array1, $array2, and $array3, are scalars, as well as being very bad names for variables?

    For now, here is a rewrite of your code using idiomatic Perl, and the $. variable that evaluates to the line number of the file most recently read

    use strict;
    use warnings;
    
    open my $file, '<', 'productR0101.asp' or die $!;
    
    my $array1;
    my @array4;
    
    while (my $line = <$file>) {
    
      chomp $line;
    
      $array1 = $line if $. == 6;
    
      if ($line =~ m/.{8}units.ml/) {
        @array4 = $line =~ m/.{8}units.ml/g;
        print "@array4\n";
      }
    }
    
    print "\n".$array1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I am trying to loop through a bunch of documents I have to put
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

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.