Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

input file

Xm_ABL1 Geneious    extracted region    1   168 .   +   .   Name=Extracted region from gi|371443098|gb|JH556762.1|;Extracted interval="3512970000000 -> 3514640000000"
Xm_ABL1 Geneious    extracted region    169 334 .   +   .   Name=Extracted region from gi|371443098|gb|JH556762.1|;Extracted interval="3717850000000 -> 3719500000000"

part of perl code

 if ($array[1] =~ /extracted region/){
            die "No CDS record for $key!\n" unless $metadata->{$key};
    (my $label = $array[7]) =~ s/.*region from (.*)\|;.*/$1/;
    $label =~ s/\|/_/g;
    $group->{$label} ||= { 
            pos1 => 1e10,
            pos2 => 0,
            metadata => $metadata->{$key},
            sequences => [],
    (my $pos1, my $arr, my $pos2) = ($array[7]=~/.*interval=\"(\d+) (<?->?) (\d+)\"$/gm);
    # capture hi/lo values for group
    $group->{$label}->{pos1} = $pos1 if $pos1 < $group->{$label}->{pos1};
    $group->{$label}->{pos2} = $pos2 if $pos2 > $group->{$label}->{pos2};
    # push this sequence onto the group's array
    push(@{ $group->{$label}->{sequences} }, [ $pos1, $pos2, $arrow->{$arr} ]);

In the code $pos1=3512970000000,3717850000000 & $pos2=3514640000000,3719500000000. My code prints new line finding minimum and maximum value (if $pos1 is less than 10,000), but if the value is greater than 10,0000 it gives error in printing minimum value of pos1. Any help is appreciated in debugging for finding minimum value of $pos1 and maximum value of $pos2

share|improve this question

closed as off topic by bahamat, manatwork, Renan, Gilles, Stéphane Gimenez Aug 20 '12 at 16:49

Questions on Unix & Linux Stack Exchange are expected to relate to Unix or Linux within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

this is a programming question: shouldn't it be on stackoverflow? – iconoclast Jul 19 '12 at 21:50
up vote 1 down vote accepted

$group->{$label}->{pos1} is always defined, you inizialized it with line 6:

pos1 => 1e10,

so that, it work right until $pos1 <= 1e10. If you want print minimum value $group->{$label}->{pos1} = 3512970000000 (like your sample input), you must inizialize $group->{$label}->{pos1} = -1 (line 6):

pos1 => -1,

and modify line 13 with:

$group->{$label}->{pos1} = $pos1 if (($group->{$label}->{pos1} < 0) || ($pos1 < $group->{$label}->{pos1}));
share|improve this answer

by changing code at Line 13: using defiend

 $group->{$label}->{pos1} = $pos1 if ((!defined $group->{$label}->{pos1})
 ||  ($pos1 < $group->{$label}->{pos1})); 
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.