in reply to Re^2: Avoiding silly programming mistakes
in thread Avoiding silly programming mistakes

It's not really necessary to do so in Perl...

Probably why I have never adopted it. That doesn't mean that there aren't people out there recommending it. For those following along at home, perl doesn't always issue a warning with the assignment operator in a conditional:

#!/usr/bin/perl use strict; use warnings; if (my $foo = foo()) { print "No warning\n"; } if (my @asdf = (1..5)) { print "No warning here either\n"; } if (my $bar = {one => 1}) { print "Look Ma, no warning\n"; } while (my $rec = <DATA>) { # ... } sub foo { return 42; }

Of these, the only suspect one is the first and perl assumes you know what you are doing. Writing it with the operands reversed would have generated an error (assuming no lvalue attributes) but I agree, this is a stretch.

You have re-inforced my two points. A lesson learned the hard way is learned best and there is no substitute for experience but figuring out how much of other's experience to rely on is tricky.

Cheers - L~R