Last active
December 28, 2015 15:19
-
-
Save kentaro/7520653 to your computer and use it in GitHub Desktop.
bool型ぽいもののオブジェクトをデバッグログ用にする例(Perl)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
package Debug; | |
sub new { | |
my ($class, $flag) = @_; | |
bless \$flag, $class; | |
} | |
sub printf { | |
my ($self, @args) = @_; | |
if ($$self) { | |
CORE::printf(@args); | |
} | |
} | |
package main; | |
my $debug_false = Debug->new(0); | |
my $debug_true = Debug->new(1); | |
$debug_false->printf('This message will not appear'); | |
$debug_true->printf('This message will appear'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
感想: LLでやっても特に面白くなかった。