G
grocery_stocker
Given
my ($title) = ($body =~ m@<title>\s*(.*?)\s*</title>@si);
What does m@ do in this case?
my ($title) = ($body =~ m@<title>\s*(.*?)\s*</title>@si);
What does m@ do in this case?
Given
my ($title) = ($body =~ m@<title>\s*(.*?)\s*</title>@si);
What does m@ do in this case?
grocery_stocker said:Given
my ($title) = ($body =~ m@<title>\s*(.*?)\s*</title>@si);
What does m@ do in this case?
grocery_stocker said:Given
my ($title) = ($body =~ m@<title>\s*(.*?)\s*</title>@si);
What does m@ do in this case?
m(anything) is making (anything) the delimiter. m// is just most common
to see, but m,, or m!! and so on, are perfectly acceptable.
Ilya said:[A complimentary Cc of this posting was sent to
Tim Greer
m(anything) is making (anything) the delimiter. m// is just most
common to see, but m,, or m!! and so on, are perfectly acceptable.
It would be correct, except for
m(anything) is using `(' and `)' as delimiters.
;-) :-(
Ilya
[A complimentary Cc of this posting was sent to
Tim Greer
m(anything) is making (anything) the delimiter. m// is just most common
to see, but m,, or m!! and so on, are perfectly acceptable.
It would be correct, except for
m(anything) is using `(' and `)' as delimiters.
grocery_stocker said:[A complimentary Cc of this posting was sent to
Tim Greer
my ($title) = ($body =~ m@<title>\s*(.*?)\s*</title>@si);
What does m@ do in this case?m(anything) is making (anything) the delimiter. m// is just most
common to see, but m,, or m!! and so on, are perfectly acceptable.
It would be correct, except for
m(anything) is using `(' and `)' as delimiters.
And what would be the reason for using ( and ) as delimiters in this
case?
grocery_stocker said:[A complimentary Cc of this posting was sent to
Tim Greer
<[email protected]>:
my ($title) = ($body =~ m@<title>\s*(.*?)\s*</title>@si);
What does m@ do in this case?
m(anything) is making (anything) the delimiter. m// is just most
common to see, but m,, or m!! and so on, are perfectly acceptable.
It would be correct, except for
m(anything) is using `(' and `)' as delimiters.
And what would be the reason for using ( and ) as delimiters in this
case?
None, I had made a poor example of saying that the "delimiter character"
would be anything, by using the example of "(anything)" as the place
holder (for the example). That could cause confusion, so Ilya called
me on it. You _could_ use parenthesis if you wanted to m() instead of
m// or m@@ or m!! or m,, and so on.
There's no reason for using any
one over another, other than personal preference, or in the case where
you can save typing and have it look cleaner, especially by not having
to backwack the same characters in the regex that you use as the
delimiter.
Martien said:grocery_stocker said:[A complimentary Cc of this posting was sent to
Tim Greer
<[email protected]>:
my ($title) = ($body =~ m@<title>\s*(.*?)\s*</title>@si);
What does m@ do in this case?
m(anything) is making (anything) the delimiter. m// is just most
common to see, but m,, or m!! and so on, are perfectly
acceptable.
It would be correct, except for
m(anything) is using `(' and `)' as delimiters.
And what would be the reason for using ( and ) as delimiters in this
case?
None, I had made a poor example of saying that the "delimiter
character" would be anything, by using the example of "(anything)" as
the place
holder (for the example). That could cause confusion, so Ilya called
me on it. You _could_ use parenthesis if you wanted to m() instead
of m// or m@@ or m!! or m,, and so on.
One more footnote to this (and I'm sure you already know this, but
others might not):
If you use ? as the delimiter, then the pattern will only match once,
until you call reset().
Even if you don't ever need this, and even if you take into account
that that usage is deprecated, it's useful to know, as it can create
some weird and obscure bugs if you choose ?? as your delimiters,
without being aware of this behaviour.
There's no reason for using any
one over another, other than personal preference, or in the case
where you can save typing and have it look cleaner, especially by not
having to backwack the same characters in the regex that you use as
the delimiter.
Using brackets, either (), {}, <> or [] can be advantageous in that
they properly nest. What I mean by that is that you only ever have to
escape a closing bracket in the pattern if it hasn't been preceded by
a opening one. If you choose non-bracket delimiters, you need to
escape your delimiter in the pattern more often.
Also, most code editors have a 'find matching bracket' functionality
somewhere, which, for checking and debugging large regexen can be
handy.
Check the section 'Quote and Quote-like Operators' in the perlop
documentation for more information.
Martien
If you use ? as the delimiter, then the pattern will only match once,
until you call reset().
grocery_stocker said:Given
my ($title) = ($body =~ m@<title>\s*(.*?)\s*</title>@si);
What does m@ do in this case?
m = match
@ = marks the beginning and end of the regular expression
my ($title) = ($body =~ m@<title>\s*(.*?)\s*</title>@si);
What does m@ do in this case?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.