In message <199911101300.PAA16873@mimosa.hut.fi>, Jarkko Hietaniemi writes: : One more from PCRE (ftp://ftp.cus.cam.ac.uk/pub/software/programs/pcre/) : author Philip Hazel. If this (rightly) fails to match : : ./perl -wle '"a" =~ /^(a)?a$/;print $1' : Use of uninitialized value at -e line 1. It does match, but greed makes the ? give up its a, leaving $1 empty: #! /usr/bin/perl -w use strict; print q{"a" =~ /^(a)?a$/}, "\n"; if ("a" =~ /^(a)?a$/) { print "\$1 = `", defined $1 ? $1 : "<undef>", "'\n"; } else { print "No match.\n"; } [9:05] ruby% ./try "a" =~ /^(a)?a$/ $1 = `<undef>' : why does this match? : : ./perl -wle '"a" =~ /^(a)?(?(1)a|b)+$/;print $1' : a That looks like a bug to me. It should match, but $1 should be empty in that case. GregThread Previous