in reply to An "ethical" use of dot-star ..?
As with most "thou shalt nots" applied to Perls TIMTOWTDI, there is a rational behind them, but just as using the proscribed technique, method or construct blindly without fully understanding what it actually does and the implications that come from it is dangerous, so blindly trying to avoid the proscribed behaviour without understanding the reasoning is equally bad. Maybe more so.
Sometimes the 'grab all you can' behaviour is exactly the semantic that you need. One assumes, that as it is the 'default' behaviour, the people that designed and maintain the regex engine consider this to be the prevelant requirement.
Death to Dot Star! and freinds serve the very useful purpose of highlighting the implications of using the feature in an unconstrained way with regard to the implications. However, dogmatically not using the construct, when it is the right tool for the job is equally bad and 'cargo-cultish'.
Noone would advocate the total removal of the 'rd -r *' facility, despite the very real disasters that can ensue from its incorrect use.
<tongue-firmly-in-cheek>
Maybe Perl should prompt the programmer (or even popup a dialog:) with "Are you sure you want to .*"? when ever it encounters a regex that uses it. Or maybe a new /* regex option is called for that says "Yes, I'm using .* and its ok. I'm a programmer and I know what I'm doing" :)
</tongue-firmly-in-cheek>
|
|---|