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:
Error:Use of uninitialized value in numeric eq (==)

 



gevni
Novice

Dec 16, 2012, 12:58 AM

Post #1 of 3 (1489 views)
Error:Use of uninitialized value in numeric eq (==) Can't Post


Code
my $j=0; 
my $col_data;
my @new_array;
my $series;
my @group;
my $previous;
for($i=0; $i <$nb_col ; $i++){
$col_data= $partition->[$i];
@new_array = ();
my @group= sort@{$group_id->[$i]};
print Dumper @group;
for($j=0;$j <= $#$col_data; $j++){
unless (defined $previous) {
$previous = $j;
$series = $j;
next;
}
if($group[$previous]== $group[$j]){
$series .= "_" . $j;
}
else
{
push @new_array, $series;
$series = $j;
}
$previous = $j;
}
push @new_array, $series;
print " @new_array\n";
$size_col[$i] = $#new_array+1;
}
#print " @new_array\n";
print Dumper @size_col;




Code
Its output is 
$VAR1 = '0';
$VAR2 = '0';
$VAR3 = '0';
$VAR4 = '1';
0_1_2 3
$VAR1 = '1';
$VAR2 = '1';
$VAR3 = '2';
Use of uninitialized value in numeric eq (==) at ./partition.pl line 62.
3 0_1 2
$VAR1 = '1';
$VAR2 = '2';
$VAR3 = '3';
$VAR4 = '3';
2 0 1 2_3
$VAR1 = '2';
$VAR2 = '2';
$VAR3 = '2';
$VAR4 = '2';
$VAR5 = '2';
2_3_0_1_2_3_4
$VAR1 = '2';
$VAR2 = '3';
$VAR3 = '4';
$VAR4 = '1';


It works fine but only issue is it connect the last element of previous array to the first element of next array. How can i exclude it like first array 0_1_2 3 is fine the next array is 3 0_1 2 instead it should be 0_1 2. Thanks


wickedxter
User

Dec 17, 2012, 5:41 PM

Post #2 of 3 (1472 views)
Re: [gevni] Error:Use of uninitialized value in numeric eq (==) [In reply to] Can't Post

how about a description of what your trying to accomplish. What is your data set going in to the code.

the warning is poping up beacuse in one of the $group[$previous] or $group[$j] is undef.
so youll have to come up with something to either next, last or check for an undef value in the @group array. This can happen if one array has more then the other.


(This post was edited by wickedxter on Dec 17, 2012, 5:42 PM)


gevni
Novice

Dec 18, 2012, 4:13 AM

Post #3 of 3 (1458 views)
Re: [wickedxter] Error:Use of uninitialized value in numeric eq (==) [In reply to] Can't Post

Yes I sorted our my problem , I just add $previous=undef; statement in the code and it works fine.

 
 


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

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