ambrus has asked for the wisdom of the Perl Monks concerning the following question:
The following code is a simple hello world program preceded with a source filter that doesn't actually change the code in any way. This code works for me (in either perl 5.10.0 or 5.8.8 on x86-linux), that is, it prints hello world.
use Filter::Util::Call; BEGIN{ filter_add(sub{ my $s = filter_read; my $t = $_; $_ = $t; # <--- $s; }); } print "hello, world\n";
However, if I remove the line marked with the arrow, the resulting code,
use Filter::Util::Call; BEGIN{ filter_add(sub{ my $s = filter_read; my $t = $_; $s; }); } print "hello, world\n";
does not work anymore: specifically it does not print anything and exits with exit code 0.
I can't see why that statement makes a difference. Please explain.
Update 2008 jan 31: sent perl bug report.
Update 2008 feb 6: yes, sent it, but forgot to link to it. It's bug 50430.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Wierd behaiviour of Filter::Util::Call
by BrowserUk (Patriarch) on Jan 29, 2008 at 21:08 UTC |