If 5.10+ is available, use of the //p regex modifier allows ${^MATCH} (and friends) to be used eliminating the need for an explicit capture and perhaps slightly speeding the matching:
>perl -wMstrict -lE
"my $line = q{as specified, line has: no digits (0-9); letters!};
;;
say qq{'${^MATCH}' found at $-[0]}
while $line =~ m{ [ (),.;:?!-] }xmsgp;
"
' ' found at 2
',' found at 12
' ' found at 13
' ' found at 18
':' found at 22
' ' found at 23
' ' found at 26
' ' found at 33
'(' found at 34
'-' found at 36
')' found at 38
';' found at 39
' ' found at 40
'!' found at 48
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|