eweaverp has asked for the wisdom of the Perl Monks concerning the following question:
Hola Monks...
I was looking at the qr// operator the other day, and came across this, from perlop:
The result may be used as a subpattern in a match: $re = qr/$pattern/; $string =~ /foo${re}bar/; # can be interpolated in other patter +ns $string =~ $re; # or used standalone $string =~ /$re/; # or this way
And I came to the conclusion that I had no clue what was going on in the /foo${re}bar/ snip. Why the {}'s in this case? Not repetition, I assume. And why is '$' outside of them? Why is 're' not treated as a fixed string? If someone could spell out what exactly this means, I would appreciate it.
Confusedly...
~evan
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: /foo${re}bar/
by fglock (Vicar) on Jul 27, 2003 at 04:00 UTC | |
by eweaverp (Scribe) on Jul 27, 2003 at 04:19 UTC | |
by BUU (Prior) on Jul 27, 2003 at 04:22 UTC | |
|
Re: /foo${re}bar/
by hossman (Prior) on Jul 27, 2003 at 05:38 UTC | |
|
Re: /foo${re}bar/
by revdiablo (Prior) on Jul 27, 2003 at 04:00 UTC |