Michael G Schwern wrote:
> On Sun, Oct 26, 2003 at 04:45:48PM +1100, Andrew Savige wrote:
>> There is a misprint in this line:
>>    my $have_testpod = !$@ and $Test::Pod::VERSION >= 0.95;
>> It should read:
>>    my $have_testpod = !$@ &&  $Test::Pod::VERSION >= 0.95;
>
> I deliberately used and instead of &&.  I'd noticed the original was
> using explicit parens to disambiuate the precendence to make sure there
> was no chance of it accidentally evaluating as:
> 
>     (!$@ && $Test::Pod::VERSION) >= 0.95
> 
> for those of us that don't have the symbol table memorized.  Instead of
> parens, I went with 'and'.
> 
> But looking at the precdence table, either version will work.

Your version does not work (unless I've had a brain malfunction):

# cat sch.pl
use strict;
eval 'use Test::Pod';
my $have_testpod = !$@ and $Test::Pod::VERSION >= 0.95;
print "have_testpod='$have_testpod'\n";
print "tpv=", $Test::Pod::VERSION, "\n";

# perl -w sch.pl
Useless use of numeric ge (>=) in void context at sch.pl line 3.
have_testpod='1'
tpv=0.94

# perl -MO=Deparse -e \
> 'my $have_testpod = !$@ and $Test::Pod::VERSION >= 0.95'
$Test::Pod::VERSION >= 0.95 if my $have_testpod = !$@;
-e syntax OK

>> Based on the excellent work from Lester & Schwern, I could not restrain
>> myself from shortening this a little more (since it will be included
>> in many distributions).
> 
> The logic escapes me.  Clarity is more important than length if you're
> going to be sticking this code all over the place.

I'm not going to pretend it's rational, but for some reason I feel more
comfortable with cut n' pasting if it's only a small amount of code.

This reminds me of the many recent discussions re the merit of:
   $s = do { local $/; <$fh> };
versus using File::Slurp. Psychologically, it may be easier to justify
cut n' pasting if you can say "oh, it's just a one-liner".

> But if we're going to encourage people to copy this code, Test::Pod
> should probably just have a subroutine to do this for you.  That's
> what libraries are for!

I hope Andy is listening. ;-)
Yes, I agree it'd be nice for Test::Pod to provide a little more help
for this very common chore for CPAN module authors. I do feel most
uncomfortable cut n' pasting this code all over the place.

/-\


http://personals.yahoo.com.au - Yahoo! Personals
New people, new possibilities. FREE for a limited time.

Reply via email to