Can you spot why this code does not do anything? Well, it took me 15 minutes, anyway. It was 6 am, but that does not really excuse anything.
if( undef $value ) { null_style() } elsif( $value eq NONE ) { null_style() } elsif( $value eq DEFAULT ) { default_style() } elsif( $value eq SURPRISE_ME ) { surprise_me() } elsif( $value =~ m/^LOCAL:(.*)/ ) { local_style( $1 ) } elsif( $value =~ m/^URL:(.*)/ ) { redirect( $1 ) }
Before everyone decides to tell me what is wrong, I really do know how to test if a variable is defined. I just have this new keyboard that I am getting use to.
The other biggie for me is using == when I should have used 'eq'... for some reason I can read it a dozen times and not notice the problem.if ($a = 0){
# do something
}
Re:reminds me...
drhyde on 2004-05-24T07:27:59
If youuse warnings
perl would catch this for you.Re:reminds me...
brian_d_foy on 2004-05-24T10:56:37
Of course, of course...
In this case, 'use warnings' was the problem. I had to transfer this stuff to a system that had perl5.005, then had to remove that pragma. It was early in the morning and I neglected to add -w to the shebang line.
But then, that's why I choose the title I used.Re:reminds me...
Aristotle on 2004-10-26T07:15:01
If you write that as0 == $a
, the compiler will balk if you forget the extra equals sign.