Given that source filters "don't work for eval" and I've not found any way around that limitation, the most straightforward fix will be to copy the implementation of the code_no_comment handling from Filter::Simple which uses Text::Balanced to do its magic.
There may be a very clever way to get Filter::Simple and such to work from eval but I think it will be much quicker to reimplement/copy and move on... I observe that that is pretty much what was done for the current interactive PDL::NiceSlice support. --Chris On Mon, Oct 10, 2011 at 8:27 AM, chm <[email protected]> wrote: > On 10/9/2011 11:17 PM, Craig DeForest wrote: >> >> This is really cool, thanks very much! >> >> In the long term, I hope we eventually just switch >> over once everyone's happy -- I get very nervous >> when environment variables get too prominent for >> interpreting one's code... > > The PDL_NICESLICE_ENGINE is there so that > folks can use/test with and without the new > engine without changing their code. The > plan is to go to a parameter in perldl.conf, > replacing the PDL_NICESLICE_ENGINE run-time > check by build-time configuration. > > The new engine works for program files but > the translation in perldl and pdl2 evals still > needs to be implemented. > > Basically the code for both engines uses the > perldlpp routine for the filtering. However, > the Filter::Simple does some filtering of the > source *before* handing it off to perldpp. > That needs to be replicated. It sure would > be nice if source filters could work in > evals... > > Cheers, > Chris > > >> On Oct 9, 2011, at 8:35 PM, chm wrote: >> >>> PDL::NiceSlice users: >>> >>> I just pushed to PDL git a refactoring of the >>> PDL::NiceSlice source filter to allow for >>> different filter engines. Thus you can choose >>> either the original engine based on the >>> Filter::Util::Call module or the new filter >>> engine using Filter::Simple by setting the >>> environment variable PDL_NICESLICE_ENGINE to >>> the desired engine module name. >>> >>> The new engine avoids source filter changes >>> within perl comments/POD and within most >>> string contexts (source filtering can still >>> happen within the / / of a pattern operator. >>> If this is an issue, just use the m/ / form >>> instead). >>> >>> Here is an example of a test case based on >>> the original sf.net bug report with a SQL query >>> string being constructed in a string: >>> >>>> $ cat ttt.pm >>>> use PDL::NiceSlice; >>>> >>>> $table = 'ZEB21'; >>>> $yr = 1991; >>>> $schema = 'schema'; >>>> >>>> >>>> print qq{ >>>> CREATE TABLE $table ( >>>> CHECK ( yr = $yr ) >>>> ) INHERITS ($schema.master_table) >>>> } . "\n"; >>>> >>> >>> >>> This is the output from the original PDL::NiceSlice >>> filter engine: >>> >>>> $ perl -Mblib ttt.pm >>>> >>>> CREATE TABLE ZEB21 ->nslice(CHECK(yr=1991)) INHERITS >>>> (schema.master_table) >>>> >>> >>> >>> Here is the result from the Filter::Simple engine: >>> >>>> $ PDL_NICESLICE_ENGINE='Filter::Simple' perl -Mblib ttt.pm >>>> >>>> CREATE TABLE ZEB21 ( >>>> CHECK ( yr = 1991 ) >>>> ) INHERITS (schema.master_table) >>>> >>> >>> >>> Enjoy! >>> Chris >>> >>> _______________________________________________ >>> Perldl mailing list >>> [email protected] >>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl >>> >> >> >> >> ----- >> No virus found in this message. >> Checked by AVG - www.avg.com >> Version: 10.0.1410 / Virus Database: 1522/3943 - Release Date: 10/07/11 >> >> >> > > _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
