John--
The eq operator looks for an exact match of the left and right value, whilst the =~ operator checks to see if the string on the left contains the regular expression on the right side.
The problem is that the string you're using contains characters in it that have special meaning when they're inside a regular expression. In this case, these are the parenthesis. For your regular expression argument, try escaping the special characters, like so:
perl -e '$a="MIN.(NERR_VOL2)"; $b="MIN.\(NERR_VOL2\)" ; $x = ( qq/$a/
+=~ qq/$b/ ) ; print "$a == $b ? $x \n" ;'
You'll want to read the 'perlre' documentation to see what's going on here.
Note 1: There's another character in the expression that has special meaning in your regular expression, but it didn't hurt you in this case.
Note 2: Another thing: You should never assign a variable like so:
$b = "$a";
You're telling perl to create a string, and since it has an expression inside the string, you're telling it to interpolate the value. The end result is that you're asking Perl to do a lot more work to get the result you
really want:
$b = $a;
which tells Perl to simply copy the value of $a into $b.
--roboticus
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.