Skip to content

Instantly share code, notes, and snippets.

@tokuhirom
Created December 18, 2008 05:29
Show Gist options
  • Save tokuhirom/37392 to your computer and use it in GitHub Desktop.
Save tokuhirom/37392 to your computer and use it in GitHub Desktop.
sub strip_nl (&) {
my $code = shift;
my $mtref = do {
no strict 'refs';
${__PACKAGE__ . '::_MTREF'};
};
my $before = $$mtref;
$$mtref = '';
$code->();
$$mtref =~ s/^\s+//smg;
$$mtref =~ s/[\r\n]//g;
$$mtref = $before . $$mtref;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment