in reply to Re^4: Checking for occurrence in comma separated string
in thread Checking for occurrence in comma separated string
I'd DTRT: split on comma, and compare with eq.
Eeek! Compare with eq? So, you really don't want to know whether "1.234e-5" is numerically the same as ".00001234"? Or, for that matter, "1", "1.0", and "1.00" should all be different?
Oh, and should this list: "1.0, 2.0" be considered different than "1.0,2.0" (because you are splitting on commas and not removing space?)
I suspect you just misspoke there with the eq comment.
The way I'd approach this would be to split on /\s*,\s*/ and use numerical comparisons. I'd allow spaces in input because if they weren't, that would probably be the most common input error and it's pretty cheap to avoid—be liberal in what you accept and conservative in what you emit, and all that. The caveats to this approach are that you are limited in precision to what your perl provides and the input format is rigid (even with optional spaces.)
-sauoq "My two cents aren't worth a dime.";
|
|---|