Peter Scott wrote:
> Although it turned out not to be what was going on here, just to address 
> your subject line' it's not just Perlcritic that will complain about 
> assignment in a conditional, but also warnings:
> 
> % perl -wle 'print 42 if $x = 0'
> Found = in conditional, should be == at -e line 1.
> 
> And of course you should always have warnings enabled, and always make 
> sure your program doesn't output any.

heh.

Thanks for picking up on my thread.

fyi, and fwiw, I always, _always_, *ALWAYS* start my scripts, tests,
packages and modules with the shebang line:

#!/usr/bin/perl # doesn't everyone have it here ;P

...followed by a single empty line...

...followed by warnings and then strict. I don't have any particular
order for the two. I often wonder though whether I have a psychological
issue that has me type 'use warnings' before 'use strict' some days, and
then on other days, I do it the opposite.

Either way. You will *never* find anything that I have written,
regardless of how bad it may be, that doesn't start with:

#!/usr/bin/perl

use strict;
use warnings;

use Something::Else;

use My::Something;

...yes, I truly do ALWAYS leave the empty line before the next use
statement after the mandatory pragmas. I'll also leave a blank line
between CPAN modules and the modules I wrote myself.

I've been getting into a habit however of removing the whitespace
between use Something::Else and MY::Module in cases where I feel that my
work is CPAN semi-quality but I haven't received my PAUSE ID yet ;)

> Note that there is or at least used to be also a side effect in perl that 
> would cause that warning if there was an assignment "nearby" a 
> conditional, even if not where you'd think it ought to be to complain.  I 
> forget the details exactly and haven't hit it again in eons.

Does the side effect affect Perl or perl?

I'm content in knowing that if Uri, John, Shlomi, Shawn etc had noticed
such a nearby side-effect, I'dve heard about it eons ago ;)

Cheers,

Steve

ps. even in my one-liners, I have a hell of a time not using
strict/warnings, and I especially cringe at not lexicalizing my variables!



> 


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