#!/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 }
–hsm
"Never try to teach a pig to sing…it wastes your time and it annoys the pig."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting a Handle on the un-rulely STDOUT
by John M. Dlugosz (Monsignor) on Jul 12, 2002 at 19:44 UTC | |
by hsmyers (Canon) on Jul 12, 2002 at 21:14 UTC |