|
|
| XP is just a number | |
| PerlMonks |
Iterating over code embeded in regexby eibwen (Friar) |
| on Jun 13, 2006 at 03:30 UTC ( #554941=perlquestion: print w/ replies, xml ) | Need Help?? |
|
eibwen has asked for the
wisdom of the Perl Monks concerning the following question:
I'd like to run a few lines of code on each instance of a string of a particular form. To accomplish this I've been using a regex of the form:
While this works to print all occurances of the string in question (see Global Regex sans //g), I cannot seem to get this to work in list (or perhaps array) context:
The code seems to run each iteration; however instead of printing the current value of $letter, it returns the following error: Use of uninitialized value in print at (re_eval 1) line 1. As I type this I wonder if the regex and the embeded code are being compiled prior to the instantion of the variable? I tried running it through Deparse, but it appeared to be more or less unaltered. Should this be the case, I'd surmise it happens afterwards -- perhaps at runtime? How can I print the current value of the iteration from within the regex -- preferrably sans eval?
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||