Mark_Galeck wrote:
Hello, I want to write a simple debug-print subroutine, which you
could call like this:
$foobar = "foobar";
dbgPrint foobar;
You could use a source code filter to rewrite
dbgPrint $foobar;
into
dbgPrint('$foobar', $foobar);
So you sub would be like
sub dbgPrint($$) {
my($name, $value) = @_;
print "$name = $value\n";
}
Take a look at:
Acme::Lingua::Pirate::Perl
I think a regular expression like
s/dbgPrint\ (.*)\;/dbgPrint\('$1', $1\);/
would do the trick. Maybe you have to wiggle it a bit, though, depending
on how you want it.
This may not result in beautifull code, but it should get the job done
nicely... (code like this makes Java Developers cry out in pain, which
is EXACTLY what we Perl hackers need to relax ;-)
LG
Rene
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/