Dave Adams wrote:
Does perl allow you to conditionally include a module?

For example:

#!/usr/bin/perl -w
use strict;
my $DEBUG = 0;
if (DEBUG) {
    use diagnostics;
}
my $filename = "test$$.txt";
open (FH , ">$filename") || die "error: $!";
print (FH "hi");
close (FH);

Although this is a simple and silly example, it would be nice to be
able to include the diagnostic module by setting my debug to true.

Any Comments?
DA


If you're using Perl 5.7.3 or later you can

    use if $DEBUG, diagnostics -verbose;

details in 'perldoc if'

:)

And all you people who answered with something other than this, aren't you ashamed you didn't know about 'if' ? :)

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


Reply via email to