I wonder why it is necessary to match something like 'AZZ' and yet grab an undefined value from it.
Good point. This made me rethink my problem. In my case, the grabbed part is not really kept in a variable (I wrote it in that way in the hope to make the whole posting simpler), but within a substituion (to be precise, an insertion): I need to change a text AXZ into AXIZ, where the X is optional. In otherwords, I have to insert I in front of the Z, so in the substitution I use
s/..../A$1IZ/
, and if I know that $1 is always defined, I don't have to care about interpolating an undefined value. In hindsight, I now see that I should better have written
s/^(A(?:\s.*?)?(Z))/$1I$2/
. :-(
--
Ronald Fischer <ynnor@mm.st>
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.