in reply to Regexp: not what I'd expected

Everyone else has answered the "Why did this happen?" questions, so I'll go for the "What book..." question. _Mastering Regular Expressions_ by Jeffrey Friedl is still the standard, even though it's a bit dated by now. It may also be more than you need. Fortunately, perl comes with a whole boatload of documentation for free. perldoc perlop first to read about the m// and s/// operators and their flags, and then perldoc perlre to get hip deep in Perl regexes. Enjoy!