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/


Reply via email to