Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: Regular expression match trouble with "+"

by perladdict (Chaplain)
on Aug 17, 2006 at 09:43 UTC ( #567865=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Regular expression match trouble with "+"
in thread Regular expression match trouble with "+"

hi monk, try by replacing eq by '==' sign in if condition,it will work.
if($a == $b)


Comment on Re^3: Regular expression match trouble with "+"
Re^4: Regular expression match trouble with "+"
by davorg (Chancellor) on Aug 17, 2006 at 10:00 UTC
    hi monk, try by replacing eq by '==' sign in if condition,it will work

    Are you suggesting code like this:

    $a = "I have to get the + version"; $b = "I have to get the + version"; if ($a == $b) { print "Ok\n"; } else { print "Not the same...\n"; }

    If so, that's some of the worst advice that I've seen on this site. The "==" operator works by converting its arguments to numbers and comparing those. In this case both of the strings will be converted to zero for the comparison, so they _will_ be equal. But there is a huge (effectively infinite) set of strings that are evaluated as zero when used as numbers. Most of these should not match in this case, but will with your code.

    Please be more careful with the advice you post here.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2014-12-25 19:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (162 votes), past polls