my $def1 = 'true'; my $def2 = 'foo'; my $def3 = 'blue'; my $undef1; if ( $def1 =~ /X/ ) { # <-- problem reported here print 'not here'; } elsif ( $def2 =~ /Y/ ) { print 'not here either'; } elsif ( $undef1 =~ /$def3/ ) { # <-- problem exists here print 'oh noes'; } else { print "happiness ensues\n"; }