On 09/11/2012 17:08, Nemana, Satya wrote:
Hi

I am a little confused with this program

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)

Output:
Use of uninitialized value in numeric eq (==) at wrong1.pl line 4.

not equal


However, if I replace $999 with $num (which is not defined or initialized), I 
get the following error

Global symbol "$num" requires explicit package name at wrong1.pl line 4.
Execution of wrong1.pl aborted due to compilation errors.

What is happening with the top program?

Hello Satya

The variable $999 holds the 999th capture from the most recent regular
successful expression match. Since you have no regular expressions in
the program it is left undefined. It would be very unusual to have so
many captures in a regex but Perl does support it.

Rob


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to