Hi there,

Allow me to correct myself, the value of the assignment is the new value of the 
variable. But in the end it is the same. The compiler won't be able to see what 
$bar is when used in if ($foo=$bar), therefore won't throw any warnings.

Cheers,
Jing
On 15 Aug 2013, at 01:21, Alexey Mishustin <shum...@shumkar.ru> wrote:

> Hello all,
> 
> If I make a typo and write a single "equals" operator here:
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> my $foo = 1;
> my $bar = 2;
> 
> if ($foo = 2) {
>       print "yes\n";
> }
> else {
>       print "no\n";
> }
> 
> ...then the "warnings" pragma works OK and tells me "Found = in
> conditional, should be ==..."
> 
> But if I make the same typo and write a single "equals" operator there:
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> my $foo = 1;
> my $bar = 2;
> 
> if ($foo = $bar) {
>       print "yes\n";
> }
> else {
>       print "no\n";
> }
> 
> ... then I get no warning; the script output is "yes".
> 
> Why is it so?
> 
> How could I catch such typos?
> 
> -- 
> Regards,
> Alex
> 
> -- 
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
> 
> 


--
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