On Fri, Nov 9, 2012 at 11:08 AM, Nemana, Satya <snem...@sonusnet.com> wrote:

> Program:
> use strict;
> use warnings;
>
> 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)
>

Perl interprets $999 as "the nine hundred and ninety-ninth sub-group of the
last regular expression". It's a special variable. It has no value, which
is what the warning tells you.

Perl expects program variables to start with a letter or underscore. So
"$a999" or "$num" work like you expected.

You can find more about variable names here:
http://perldoc.perl.org/perldata.html.

-- 
Robert Wohlfarth

Reply via email to