in reply to Interpolation differences between Strings and Regular Expressions
You've run into probably the most vague area of Perl parsing DWIMery. It is the only place in the Perl source code that mentions "weigh". How to interpret such things in a regex is determined by weighing several different criteria so there is no easy explanation as to what Perl will choose. For example, I'm disappointed that in a regex Perl chooses to interpret [$] as the start of a character class followed by the contents of the $] variable. I think it got that DWIM aspect just wrong.
But in your case, I think Perl got the DWIM correct. The string case is fairly straight-forward and mostly just greedy parsing so it always pulls in the trailing {...} to make a hash deref unless you do something to tell it not to.
For the regex case, {5} looks more like a quantifier than like a hash key because a hard-coded number as a hash keys is a bit unlikely, though this isn't a slam-dunk winner.
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Interpolation differences between Strings and Regular Expressions (weight)
by grinder (Bishop) on Jun 13, 2007 at 06:28 UTC | |
by TimToady (Parson) on Jun 13, 2007 at 19:35 UTC |