qr// returns an object of the class Regexp. You can make methods for them like any other object. In addition, Perl knows that if it sees
/$foo/, and
$foo is an object of Regexp, it doesn't need to compile the regex, it uses the information stored in the object.
jpinyan@sushi [2:02pm] ~ #501> perl -MDevel::Peek -e 'Dump(qr/a+bc?/)'
SV = RV(0xf18d0) at 0xe46f0
REFCNT = 1
FLAGS = (TEMP,ROK)
RV = 0xe4798
SV = PVMG(0xf0a78) at 0xe4798
REFCNT = 1
FLAGS = (OBJECT,RMG)
IV = 0
NV = 0
PV = 0
MAGIC = 0xf2158
MG_VIRTUAL = 0xe336c
MG_TYPE = 'r'
MG_OBJ = 0xf0ef0
STASH = 0xef128 "Regexp"
japhy --
Perl and Regex Hacker
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.