http://qs321.pair.com?node_id=695930


in reply to Common Regex Gotchas

Maybe it's worth to include the following, which has bitten me once too: One common use is to get regexp from an external source - for instance, your commandline - into your program, so you end up having somewhere something like:

if($line =~ /$pattern/) { ... }
The trap here is when $pattern happens to be the null string, yielding the Regexp //. This special regexp, unless it is used as argument to the split function, means: "Match again the most recently encountered regexps", which can lead to pretty bizarre program behaviour.

-- 
Ronald Fischer <ynnor@mm.st>