Note for the day

Ovid on 2004-01-08T18:44:36

I've been seeing a lot of test code that looks like this:

{
  no strict;
  local *Foo::Bar::baz = sub { die "another day" };
  throws_ok {$foo->baz} 
    qr\another day\, 'simple error thrown';
}

When overriding a subroutine that is explicitly named, there is no need to turn off strict.


Ah, but there is!

chromatic on 2004-01-08T20:22:52

Since strict is often a synonym for good_taste, you have to say no good_taste; to use backwhacks as an alternate delimiter.

Re:Ah, but there is!

Ovid on 2004-01-08T20:42:20

Heh :) I tossed those in there on the spur of the moment. I thought it was fun.

Strict is like Unit Testing

DAxelrod on 2004-01-09T03:40:19

That's why I treat strict almost as a unit test. I write the code that I think will cause strict to complain, run it, and then, only when strict complains, I put it in its own block and put in a no strict. I've learned a lot about what strict does and doesn't allow this way!