Hey there all you Perl Monks, I am new to the fold so please go easy on me ;-)
My question is with regards to perl and regex...
I seem to get different results with the line...
if( /Price: \$([0-9]+\.[0-9]+)/ )
and...
$searchString = 'Price: \$([0-9]+\.[0-9]+)';
...
if ( /$searchString/ )
What is it doing?
Well it is supposed to parse my website for changes, so that if anyone does change I am notified. It seems to work fine when the actual regex is in the if itself, but it wont match when I have it assigned to the variable.
So what is my question?
Is this normal behavior? Should the fact that the regex string is contained in a variable change the final outcome of what matches and what doesn't?
P.S the content of a grabbed webpage is assigned to $_ before the if happens.
In reply to Perl & Regex
by Kzin
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.