CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
use of unitialised value problem

 



8840
New User

Oct 14, 2008, 3:42 PM

Post #1 of 2 (2004 views)
use of unitialised value problem Can't Post

Dear Perl veterans,

I have had this problem with my perl code the past two months. The soubroutine is a part of a larger program and everytime I run it I receive the warning message that there is an uninitialised value in the marked lines. I have tried to debug this for several weeks, re-writing the code but the warning message is persistent. The entire program runs and returns most of the time a desired output (at least what I think is) but sometimes fails to return an output. Many thanks in advance for any help.

The two subroutines basically do the same thing with numbers and letters.



sub number_segmentor {

my @s = @_;
chomp @s;
my @array;

for (my $gen = 15; $gen > 11; $gen--) {
my $length = @s;
my $position = '0';
while ($position < $length) {
my $count = $position + $gen;
my $p = 0;
($p += $_) for $seq[$position..$count]; #Unitialised value detected at this position, doesn't specify which variable

unless($position + $gen > $length) {push (@array, $p);}
$position++;
}
}
return @array;
}


sub letter_segmentor {

my @seq = @_;
chomp @seq;

my $length = @seq;
my @array;
my $antigen;
my $peptide;
my $position = 0;


for (my $gen = 15; $gen > 11; $gen--) {

while ($position < $length) {
my $count = $position + $antigen;
my $p = $seq[$position...$count]; #Unitialised value detected at this position, doesn't specify which variable

if (length($p) == $gen) {push (@array, $p);}
$position++;

}

}
return @array;
}


KevinR
Veteran


Oct 14, 2008, 4:37 PM

Post #2 of 2 (2001 views)
Re: [8840] use of unitialised value problem [In reply to] Can't Post

Since the error you are getting depends on the data there is no way to tell without seeing the data. If the script works and the warning is not an indication of a real problem you can use the warnings pragma:

use warnings;

and in that function use:

no warnings;

that will suppress any warnings in that block of code.
-------------------------------------------------


(This post was edited by KevinR on Oct 14, 2008, 4:38 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives