Skip to content

Instantly share code, notes, and snippets.

@tyru
Created March 10, 2009 07:49
Show Gist options
  • Select an option

  • Save tyru/76804 to your computer and use it in GitHub Desktop.

Select an option

Save tyru/76804 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use utf8;
use Perl6::Say;
use String::CamelCase qw(camelize);
say "--- cat ---";
filter_print(\*STDIN, \*STDOUT, sub { shift });
# stdin, stdout, stderr are allowed!
say "--- cat ---";
filter_print(\*stdin, \*stdout, sub { shift });
say "--- cat >&2 ---";
filter_print(\*stdin, \*stderr, sub { shift });
# I like these words though.
say "--- simple camelized ---";
filter_print(\*STDIN, \*STDOUT, sub { ucfirst lc shift });
say "--- camelized by String::CamelCase ---";
filter_print(\*STDIN, \*STDOUT, sub { camelize shift });
sub filter_print {
my ($in, $out, $sub) = @_;
$out->print($sub->($_)) while (<$in>);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment