On 5/3/07, Owen <[EMAIL PROTECTED]> wrote:
In todays listing of new CPAN modules, there was one called constants,
http://search.cpan.org/~hooo/constants-0.0027/ . The synopsis reads;

        use constants;

EXPORTS
        UNDEF = undef;
        NO = defined;
        YES = !NO;

End of synopsis!

Could someone enlighten me as why (and how) you would use this module?
TIA
Owen

This person thought it would be useful to have named values for true,
false, and for some reason decided that he/she wanted to type undef in
upper case (probably to match the way he/she is typing true and
false).  You could use it like this:

sub strings_equal {
   croak "bad args, expected more than one, got (@_)" unless @_ > 1;
   while (@_ > 1) {
       my $s = shift;
       return NO if $s ne $_[0];
   }
   return YES;
}

It is, however, a bad idea.  YES is not the only true and NO is not
the only false.  If they are only being used in the manner above they
are mostly harmless, but be careful of using them in too general a
context.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to