my $index = 0; if(open(FH, 'layout_coords')) { while($line = ) { chomp($line); @arr = (); @arr = split('\t', $line ); my $label = $node_labels[$index]; my $x = $arr[0]; my $y = $arr[1]; my $x1 = $x + 20; my $y1 = $y + 20; $canvas->createOval($x,$y, $x1, $y1,-fill => 'green'); ## I need this oval as a pie (I have the data for each node in form of a fixed array like (2,3,1,3), etc.) $canvas->createText($x,$y, -text => $label); $index++; } } else { die "can't open file layout_coords: $!"; } close FH;