Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: split versus =~

by russlo (Novice)
on Nov 10, 2022 at 15:52 UTC ( #11148105=note: print w/replies, xml ) Need Help??


in reply to Re: split versus =~ (updated)
in thread split versus =~

Honestly, what happens to the data after this step is a bit of a mystery to me. $X, $Y, and $Z are passed through some impressively scientific mathematical translations that I simply do not understand nor do I have the time to. The code is converting from polar coordinates to rectangular coordinates, pushing those values into a vector, performing some math, and then stuffing everything into several references to global variables in various states. Calling it ugly is a disservice to ugly things. The people that wrote this are so much more intelligent than I am that they did not feel the need to comment the code.

I think I was looking for an answer like "when you use split, it doesn't fibulate the $data into the cranjux, you just need to use a different delimiter is all." But life can't be simple.

I'll try using the anchors. I had tried using + over *. If nothing else works I'll try using a different delimiter coming back from the database and then converting it back just after this step. This is a CGI script (written in 2016, so that should give you an indication of the mentality here). I don't fully understand the data, so logging is not quite as helpful as you might think, and printing to the page could cause the whole thing to fall over.

Thanks anyways. Please know that my sarcasm was not directed at you.

Replies are listed 'Best First'.
Re^3: split versus =~
by hv (Prior) on Nov 10, 2022 at 17:23 UTC

    If nothing else works I'll try using a different delimiter coming back from the database and then converting it back just after this step.

    I think I would recommend doing that anyway, and doing it first. Something like a colon would be a good choice.

    This has the advantage that you can easily (I assume) test it with positive numbers to ensure it doesn't break the old use cases, and no adjustment should be needed to handle negative numbers.

    The fact that you need to "convert it back just after this step" implies that some other code will also need to extract the numbers again. That code also needs to be examined to see if it will cope with negative numbers, and my initial guess would be that it will not. I don't have enough information to guess if that code is later in the script that is under your responsibility, or in the code it hands off to.

    Unless there are compelling reasons not to, I would recommend changing to a different delimiter for the later parts as well.

Re^3: split versus =~
by LanX (Sage) on Nov 10, 2022 at 16:08 UTC
    > Honestly, what happens to the data after this step is a bit of a mystery to me. $X, $Y, and $Z are passed through some impressively scientific mathematical translations that I simply do not understand nor do I have the time to

    Honestly this could also mean that this "impressive math" can't really handle negative numbers.

    You must find a way to test your code!

    If you can't tell when it fails, how can you even know it's buggy???

    > Thanks anyways. Please know that my sarcasm was not directed at you.

    Please know that my sarcasm is always directed at every direction ;-)

    Cheers Rolf
    (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
    Wikisyntax for the Monastery

      You must find a way to test your code!
      I've scheduled a meeting with some responsible people that hopefully can tell me why this complex math keeps seeming to spit the same numbers out no matter what goes in. Hopefully they can give me some better way to test this than clicking the button repeatedly.
      Please know that my sarcasm is always directed at every direction ;-)
      Ha, good to know, thanks again.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2023-03-28 02:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (66 votes). Check out past polls.

    Notices?