Rodster001 has asked for the wisdom of the Perl Monks concerning the following question:
I am a little curious as to why this matches the second regex. My thinking is that if it is undef then it should fail. But, apparently that isn't the case. Can someone shed some light? Thanks!
#!/usr/bin/perl use strict; use warnings; no warnings ("uninitialized"); my $id = 1001; if ($id =~ /^\d*$/) { print "Match\n"; } $id = undef; if ($id =~ /^\d*$/) { print "Match\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Uninitialized variable matches regex
by kennethk (Abbot) on Mar 23, 2009 at 20:35 UTC | |
by Rodster001 (Pilgrim) on Mar 23, 2009 at 20:56 UTC | |
|
Re: Uninitialized variable matches regex
by Anonymous Monk on Mar 23, 2009 at 20:42 UTC |