On Fri, Nov 9, 2012 at 11:08 AM, Nemana, Satya <snem...@sonusnet.com> wrote:
> > if ($999 == 1056) > { > print ("\nequal"); > } > else > { > print ("\nnot equal"); > } > > What I expect: Perl to throw me an error as $999 variable is not defined, > but perl executes the code with a warning.(I don't expect the code to > compile at all) $999 is, in a sense, one of the Perl "magic" variables. This is why the definition of a Perl variable name doesn't allow the first character to be a digit. The $<digit> variables are for the RE capture storage - in this case, your asking for what was saved by 999th set of capture parens - try: use strict; use warnings; "1056" =~ /(\d+)/; if ($1 == 1056) { print ("equal\n"); } else { print ("not equal\n"); } -- a Andy Bach, afb...@gmail.com 608 658-1890 cell 608 261-5738 wk