Benjamin Goldberg <[EMAIL PROTECTED]> writes: > H.Merijn Brand wrote: > > > > On Wed 18 Dec 2002 10:45, Slaven Rezic <[EMAIL PROTECTED]> wrote: > > > Benjamin Goldberg <[EMAIL PROTECTED]> writes: > > > > > > > I've seen on comp.lang.perl.misc, a number of times that clooless > > > > programmers do stuff like: > > > > > > > > $string =~ /something/; > > > > print $1; > > > > > > > > Where a regex is performed, and no check is made to whether it > > > > succeeds or not, and then a dollar-digit variable is used. > > > > > > > > Does it seem like a reasonable idea to make regex matching in void > > > > context produce a warning? > > > > > > Maybe the user wants to use just $&, $` or $': > > > > > > $string =~ /something/; > > > print $&; > > But if the match fails, then $& will not be properly set. Without the > user checking what =~// evaluates to (that is, the match operation was > performed in void context), he cannot discover that the match has > failed. If he doesn't know the match failed, and cannot know that $& > isn't properly set.
Maybe he *knows* that the match always succeeds (e.g. because of former matches) and wants only to extract something from the string. Regards, Slaven -- Slaven Rezic - [EMAIL PROTECTED] tkrevdiff - graphical display of diffs between revisions (RCS or CVS) http://ptktools.sourceforge.net/#tkrevdiff