Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: BUG in interpolating and/or substituting NULs in strings? Message-ID: <1991May23.042900.4897@jpl-devvax.jpl.nasa.gov> Date: 23 May 91 04:29:00 GMT References: <589@kepler1.kepler.com> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 50 In article gnb@bby.oz.au (Gregory N. Bond) writes: : : >>>>> On 21 May 91 16:51:50 GMT, jwu@kepler.com (Jasper Wu) said: : : : Jasper> Greg, from perl manpage on s///: : : Jasper> ...If the PATTERN evaluates to a null string, the most recent : Jasper> successful regular expression is used instead.... : : : Well, I would have thought that : $var = ""; : is a null string, but that : $var = "\0"; : is a non-null string with a single nul character. So I would still : class it as a bug. Yes, it's a bug. I already fixed it in my copy. One of those little hanger-oners from the bad old days before Perl was 8-bitified. As long as we're on the subject of the next patch, lemme tell you some of the other things that are there. # //g in scalar context has built-in iterator while (/pattern/g) { print "$&\n"; } $matches++ while /foo/g; # //g in array context returns all matches (or all substrings if parens) ($one, $five, $fifteen) = `uptime` =~ /\d+\.\d+/g; %options = /(\w+)=(.*)/g; # //o now optimized to run as fast as compile-time pattern without eval $pattern = shift; while (<>) { print if /$pattern/o; # fastest grep in Perl now } Note, however, that //o optimization still happens after switch optimization, so if you have several matches in a row it's still worthwhile putting them into an eval. In addition, there will be an alternate set of distribution terms, called the "Artistic License". You'll be able to distribute under either the GPL or the new one, your choice. I hope to get the next patch out soon, but I'm trying to finish up another article for Unix World... Larry