Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Do you know where your variables are?
 
PerlMonks  

Re: Maximum string length

by turo (Friar)
on Feb 22, 2006 at 14:39 UTC ( [id://532073]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Maximum string length

hi Berislav,
i think, you have 2 problems on your code:

  1. for ($lb=0; $lb<length $dna; ++$lb), the lenght of the array must be length($dna) -1 (the last elemet cannot be compared with anything ... perl accepts this, though)
  2. the 'tr' only tries to convert between lowercase letters. The example you gave us have uppercase letters ... the result isn't the same ...

I've retouched your script, so the problem of the large string will not affect you
#!/usr/bin/perl -w use strict; system "clear"; print "Palindrome - gamma version\n"; print "--------------------------\n\n"; print "Please enter DNA filename: "; my $filename=<STDIN>; chomp $filename; die "No such file...exiting\n\n" unless (-e $filename); open(DNASEQ, $filename) or die "Cannot open file...exiting\n\n"; my $last_protein; my $count_of_2=0; while (<DNASEQ>) { chomp; my ($lba,$rba)= ($last_protein, undef); for (my $lb = 0; $lb < (length) - 1; ++$lb) { $lba = substr ($_, $lb, 1); $rba = substr ($_, $lb+1, 1); $rba =~ tr/atgcATGC/tacgTACG/; ++$count_of_2 if ($lba eq $rba); } $last_protein = $rba; } print "Number of 2bp palindromes: ", $count_of_2, "\n";

hope that helps :-)

perl -Te 'print map { chr((ord)-((10,20,2,7)[$i++])) } split //,"turo"'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://532073]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.