« How to make emacs and vim file mode hints work together | Main | "A work of art is never completed, it's just abandoned." - Paul Valery »

June 27, 2005

perl closure for debug printing

#!/usr/bin/perl
use warnings;
use strict;

my $verbose = shift(@ARGV);

my $dprint = make_dprint($verbose);

$dprint->("foo!", " blah, blah", "\n");

sub make_dprint {
    my $verbose = shift;
    return sub { if ($verbose) { print @_ }; };
}

Posted by ed at June 27, 2005 3:24 PM

Trackback Pings

TrackBack URL for this entry:
http://weblogs.litmusgreen.com/mt-tb.cgi/674

Comments

Post a comment




Type the characters you see in the picture above.


Remember Me?