in reply to sometimes use strict isn't enough

What you are refering to is the difference between compile-time errors and run-time errors. use strict does not catch run-time errors. Matter of, fact, the only thing that can catch run-time errors is a pair of eyes - someone else's pair of eyes usually sees it before your pair of eyes!! :D (figuratively speaking)

Good example, Perl will happily compile and run this without complaining in the least - bonus points for an explanation why:

foreach (@list) { $conn-do("insert into foo values($_)") || die; }
when i really meant this:
foreach (@list) { $conn->do("insert into foo values($_)") || die; }
So, DO rely on strict to check for the things that strict can verify. It's your brain that you shouldn't rely on - mine get's me in trouble every time at least ;)

jeffa

Replies are listed 'Best First'.
Re: (jeffa) Re: sometimes use strict isn't enough
by blakem (Monsignor) on Oct 25, 2001 at 03:05 UTC
    One slight correction...

    strict 'subs' and strict 'vars' run their checks at compile time, but the third goblin in that group strict 'refs' enables runtime checks.

    (sorry, I was inspired by the dancing skeleton on your homenode ...... ;-) )

    Consider the following code, which will toss a strict error during runtime, depending on the flip of a coin:

    #!/usr/bin/perl -wT use strict; use vars qw($foo $bar); $foo = 'x'; $bar = int(rand(2)) ? 'foo' : \$foo; print $$bar, "\n"; =OUTPUT (when rand==0) x =OUTPUT (when rand==1) Can't use string ("foo") as a SCALAR ref while "strict refs" in use at ./strictrefs.pl line 9.

    -Blake