in reply to Re: use strict Question?
in thread use strict Question?

$c = $x * $y;throws error. Global symbol "$c" requires explicit package name But ,when i use $a = $x * $y perl doesn't throwing the error. 1.I used "use strict" in the program. 1. I declared two variables $x and $y as my. 2. But i didnt declared $a or $b as my..I expected Global symbol "$a" requires explicit package name for $a and $b.But it didnt. 3. When i use $c ,it throw error. I am curious to know why while $a and $b perl not throwing the error!

Replies are listed 'Best First'.
Re^3: use strict Question?
by Khen1950fx (Canon) on Dec 07, 2009 at 12:41 UTC
    $a and $b are special package variables used by sort(), so they don't have to be declared even if you are using strict. $c isn't a special variable; hence it must be declared, and that's why it throws an error. See perlvar for more info.