Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: difference between two lines

by Corion (Pope)
on Jul 30, 2018 at 08:18 UTC ( #1219459=note: print w/replies, xml ) Need Help??


in reply to difference between two lines

What have you tried and how did your code fail?

Some ideas would be:

You could remove all spaces from both lines. If they are equal, the difference was only the blank space.

If you want to know if two lines only differ by exactly one blank space, check first, if the absolute difference in their lengths is 1. Then do the above check.

Alternatively, split both strings on spaces and check if the resulting lists are the same.

Replies are listed 'Best First'.
Re^2: difference between two lines
by vinoth.ree (Monsignor) on Jul 30, 2018 at 09:13 UTC
    Hi Corion

    I tried the first option(remove all spaces from both lines and compare). I thought there could be best way, that's why posted this question.


    All is well. I learn by answering your questions...

      So the first option worked? If so, there's no need for a "best way". If your code has some issues you'll have to be more specific, rather than hope someone provides a solution actually fits your needs without knowing them. Or if you want advice about your code, you'll have to post it.

      Edited: in hindsight my previous formulation sounded harsher than intended.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2020-07-02 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?