Hallo @ all,

i am new in this domain(perlscript) and i have a question.i have a array,i sort it,i get the last element of the array but i want to get the next element after this one.how can i do this?

for example:

$arr1=("6,3,8,1") --->>my last element is 1 and mark that is the last element
now i sort them     ---->> $arr1=("1,3,6,8")
my last element is 1 and now i want to go to the next element in the list,how can i do this? if i do something like this:$next=$last+1; --->>in this case $next will be 2 and this is not my third element in my list,i want the 3.
BR,
Phil

here is my code:

@arr[1]=("3,7,13,1,19,5,9");
@array=split(/,/,@arr[1]);
$i=0;
while(@array[$i])
{
    $i=$i+1;
}
print"Anzahl:$i\n";
@sorty=sort(Nummernsort @array);
sub Nummernsort{
    if($a<$b){
        return -1;
    }elsif($a==$b){
        return 0;
    }else{
        return 1;
    }
}

print "sort:@sorty\n";
$last=$array[$i-1];
print "last:$last\n";
$next=?
print"nextt=$next\n";

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to