in reply to grep trouble
1. IMHO using $_ to hold a pattern is anyway a bad style!
a) since the default DWIM behaviour for m/PATTERN/ is to match in $_
b) because the content of $_ could easily be affected by other side effects.
2. So what is the behavior you expect from an empty match-pattern?
Some will expect always true¹ others always false² and a third party would want a warning³.
So you should take care about valid patterns.
Cheers Rolf
1) mathematically correct
2) "empty strings are false" and "nothing to match => no match"!
3) 'Invalid pattern "" in line ...'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: grep trouble
by davido (Cardinal) on Apr 18, 2011 at 05:45 UTC | |
by LanX (Saint) on Apr 18, 2011 at 08:30 UTC | |
by LogMiner (Novice) on Apr 19, 2011 at 01:09 UTC | |
by davido (Cardinal) on Apr 19, 2011 at 04:11 UTC |