Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Argument isn't numeric in sort -- resolve or ignore?

by GrandFather (Saint)
on Feb 26, 2016 at 02:03 UTC ( [id://1156168]=note: print w/replies, xml ) Need Help??


in reply to Argument isn't numeric in sort -- resolve or ignore?

You can't ignore the warnings - they highlight an error in your code as suggested by davido.

Sort expects a compare sub to return -1, 0 or 1 meaning $a sorts before $b, $a and $b sort equivalently, or $b sorts before $a. Other values do not make sense. Returning $a does not make sense (for any usual sort anyway).

Describe in words what your sort criteria are and either the implementation will come clear to you, or we can help you achieve that.

Smart match is probably not useful here. Quite likely you can use grep instead.

Premature optimization is the root of all job security
  • Comment on Re: Argument isn't numeric in sort -- resolve or ignore?

Replies are listed 'Best First'.
Re^2: Argument isn't numeric in sort -- resolve or ignore?
by Argel (Prior) on Feb 26, 2016 at 11:59 UTC
    Duh!!! I was so focused on the smartmatch operator that I completely overlooked the problems with the return values. Good idea about grep as well. Thanks everyone, you just saved me several more hours of pain!

    Elda Taluta; Sarks Sark; Ark Arks
    My deviantART gallery

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2024-04-23 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found