#!/perl/bin/perl # # wrap.pl -- proof of concept for wrapping a function tied to STDOUT, such that you can tie it to whatever... use strict; no strict 'refs'; use warnings; use diagnostics; use IO::Scalar; use SelectSaver; for (map {glob $_} @ARGV) { my $s; wrapper((new IO::Scalar \$s),\&myFunction,$_); print "'$s'\n"; } sub wrapper { my $saver = new SelectSaver(shift); &{$_[0]}($_[1]); } sub myFunction { my $filename = shift; print "\$filename = '$filename'\n"; print <<'HERE'; template [name = "KeyValue"] (keyword,indent,value){ Keyword(text = "concat($keyword,' =')",indent = "$indent") value-of("$value") text(";") Newline() } HERE }