Capturing the zero-or-more-spaces surrounding the equals symbol is
NOT helpful... and means OP, were your suggestion adopted, would have to use $3 for the value of width.
Moreover, if there were zero-digits after the equals symbol, the data would not match OP's explicit example and implicit spec.
Update re ckj's update which is MOSTLY WRONG. Reread the above.
(\d+) captures one or more digits. (\d*) matches ZERO digits which is useless.
perl -e "use 5.014; my $foo= 'bc'; if ($foo = /(\d*)/ ) {say 'match';
+}else{ say 'Duh!';}"
match
OP does not ask to capture the spaces. There is no need to capture the spaces to account for their quantity; 0, 1, 2 or whatever.
Your parens are capturing. Grouping (aka 'non-capturing') parens are (?:...).
Nothing was said about
print.
And "not helpful" ne "not match."
Please read carefully before unburdening yourself of mis-statements.
Despite it's irrelevance here, though, you did get one aspect of your reply partially right: "TIMTOWTDI." But -- as the rest of that wisdom goes - 'and most of them are wrong.'
</Update>
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.