On Mon, Aug 1, 2011 at 6:29 PM, Jim Gibson <jimsgib...@gmail.com> wrote: > Dr. Ruud is demonstrating the little-known but documented feature of Perl > that the explicit empty regex // repeats the last, successful regex within > its scope. Thus, in Dr. Ruud's sample program, the line > > my @result = $text =~ //g; > > is equivalent to the line > > my @result = $text =~ /[aeiou]/g; > > because that was the regex used in the last successful match. > > Of course, in a beginner's list, it is better to explain such exceptional > cases, rather than just showing the statements. or people may miss the point > entirely. But not everyone has the time or inclination to do so, > unfortunately.
I had some trouble finding it with some lazy perldoc /searching so I had #perl help out. :-X This is documented in perldoc perlop under the heading "The empty pattern" (if anybody else has troubling finding it). :) It took me executing Dr. Ruud's example before I believed the result. :P Then it took adding print statements on every line to demonstrate that the variable wasn't changing throughout his program (not that I thought it should be, but I just didn't know what was happening). Then it took reading perldoc -f split to understand WTF was happening. By then I just had to find the official documentation for the feature to satisfy my curiosity. :\ -- Brandon McCaig <http://www.bamccaig.com/> <bamcc...@gmail.com> V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl. Castopulence Software <http://www.castopulence.org/> <bamcc...@castopulence.org> -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/