http://www.perlmonks.org?node_id=567865


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

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re^3: Regular expression match trouble with "+"

Replies are listed 'Best First'.
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