Acme::Don't - The opposite of do
do
This document describes version 1.01 of Acme::Don::t, released May 3, 2002.
use Acme::Don't; don't { print "This won't be printed\n" }; # NO-OP
The Acme::Don't module provides a don't command, which is the opposite of Perl's built-in do.
don't
It is used exactly like the do BLOCK function except that, instead of executing the block it controls, it...well...doesn't.
do BLOCK
Regardless of the contents of the block, don't returns undef.
undef
You can even write:
don't { # code here } while condition();
And, yes, in strict analogy to the semantics of Perl's magical do...while, the don't...while block is unconditionally not done once before the test. ;-)
do...while
don't...while
Note that the code in the don't block must be syntactically valid Perl. This is an important feature: you get the accelerated performance of not actually executing the code, without sacrificing the security of compile-time syntax checking.
Doesn't (yet) implement the opposite of do STRING. The current workaround is to use:
do STRING
don't {"filename"};
The construct:
don't { don't { ... } }
isn't (yet) equivalent to:
do { ... }
because the outer don't prevents the inner don't from being executed, before the inner don't gets the chance to discover that it actually should execute.
This is an issue of semantics. don't... doesn't mean do the opposite of...; it means do nothing with....
don't...
do the opposite of...
do nothing with...
In other words, doin nothing about doing nothing does...nothing.
You can't (yet) use a:
don't { ... } unless condition();
as a substitute for:
do { ... } if condition();
Again, it's an issue of semantics. don't...unless... doesn't mean do the opposite of...if...; it means do nothing with...if not....
don't...unless...
do the opposite of...if...
do nothing with...if not...
Damian Conway (damian@conway.org)
Luke Palmer really should be far more careful what he idly wishes for.
Unlikely, since it doesn't actually do anything. However, bug reports and other feedback are most welcome.
Copyright (c) 2002, Damian Conway. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the terms of the Perl Artistic License (see http://www.perl.com/perl/misc/Artistic.html)
To install Acme::Don::t, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Acme::Don::t
CPAN shell
perl -MCPAN -e shell install Acme::Don::t
For more information on module installation, please visit the detailed CPAN module installation guide.