You have not said what you are trying to do, or what behavior you expect, so all I can do is make some observations:
- The documentation for (??{ *code* }) begins: "WARNING: Using this feature safely requires that you understand its limitations." For me this would be a red flag strongly suggesting that whatever you are trying to do you should choose a different implementation.
- The aforesaid documentation says that whatever the code returns is treated as a fragment of your regular expression. Absent an explicit return, your code returns whatever its last statement (a print) returns. This is documented as a true value, which means pretty much anything but undef, 0, or '', and may well vary from execution to execution.
- Modifying any Perl variable resets its pos(), which is the regexp engine's notion of where it is in the string it is matching. I suspect it would take someone with deep knowledge of the regex engine to say what it will do if you modify pos() (or the variable itself) while it is being matched, and I further suspect that whatever it does may vary from release to release.
The usual way to modify a string is to use the substitution operator s/regexp/replacement/.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|