Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Assist in understanding of old code

by talexb (Chancellor)
on Feb 28, 2005 at 22:58 UTC ( [id://435220]=note: print w/replies, xml ) Need Help??


in reply to Assist in understanding old code

#@indexUlt=sort{$nxxult[$a]<=>$nxxult[$b]} 0 ... $#nxxult;

I would have said that one of the values in the array that's being sorted is undefined, except the whole line appears to be commented out. What's really going on with this code, do you know?

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Replies are listed 'Best First'.
Re^2: Assist in understanding of old code
by ozgurp (Beadle) on Feb 28, 2005 at 23:18 UTC
    Sorry it should not have been commented out, so the code is:
    my $ct=0; my @nxxult = (); my @Ultmnsort = (); my @indexUlt = (); for(my $rn=4;$rn<=32;$rn +=4) { for(my $bn=1;$bn<=$row[0];$bn++) { $nxxult[$bn]=$ldx[$bn][$rn]; } @indexUlt=sort{$nxxult[$a]<=>$nxxult[$b]} 0 ... $#nxxult; $Ultmnsort[$ct]=$indexUlt[0]; $Ultmxsort[$ct]=$indexUlt[$#indexUlt]; $ct++; }
    I don't really know what is going on in this code, I am working on it.

      Well then, if the line shouldn't actually be commented out, then the problem is as talexb described, "one of the values in the array that's being sorted is undefined." You have two ways of solving that problem:

      • Use an empty string value instead of undef
      • Turn off the warning

      Which solution you pick will usually depend highly on the application. I tend to structure my apps in a way that an empty string makes more sense than undef, but perhaps this one isn't. In that case, turning off the warning (using a lexically scoped no warnings) would be the best option.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://435220]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-03-29 04:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found