Skip to content

Instantly share code, notes, and snippets.

@kentaro
Last active December 28, 2015 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kentaro/7520653 to your computer and use it in GitHub Desktop.
Save kentaro/7520653 to your computer and use it in GitHub Desktop.
bool型ぽいもののオブジェクトをデバッグログ用にする例(Perl)
#!/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');
@kentaro
Copy link
Author

kentaro commented Nov 18, 2013

感想: LLでやっても特に面白くなかった。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment