brian is a big, fat dumbass

brian_d_foy on 2004-05-22T11:13:37

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.


reminds me...

phillup on 2004-05-22T20:52:21

of my most common mistake. It takes this form:
if ($a = 0){
  # do something
}
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.

Maybe a few more years will help...

Re:reminds me...

drhyde on 2004-05-24T07:27:59

If you use 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 as 0 == $a, the compiler will balk if you forget the extra equals sign.

new keyboard

offerk on 2004-05-23T13:24:37

I just have this new keyboard that I am getting use to
He he he... Funny :-)
I think I'll use it in a new sig:
-------------------------
This is my sig. It's not much since I just have this new keyboard that I am getting use to ... :)
-------------------------


BTW, why weren't you running under "-w"? That would have immidiatly caused perl to shout "Use of uninitialized value in string eq ...", which is quite a strong hint at what's wrong :-)

------------------
Offer Kaye