Vincent Pit <p...@profvince.com> writes: >> When calling out to perl doing system "perl ..." is incorrect first of >> all because the current perl might not be the one in PATH. >> >> It is better to use $^X or to use Probe::Perl >> >> So I wonder if there could be (or if there already is) a CPAN smoker setup >> where the only "perl" in PATH is a fake perl that catches the >> cases when something is trying to execute it - a honeypot - that could be >> then reported to the author with the hope s/he will fix the module. >> >> Is someone already doing this? >> >> regards >> Gabor >> > > I think Slaven talked about doing this. > > I recently considered doing it as well, but I realized that would break > "system 'foo'" where foo is a perl script that may righteously want be > interpreted by the default perl in the path, and then I wasn't sure anymore. >
My smoker has the option, but it is not on by default. The snippet looks like this: { require File::Temp; my($tempdir) = File::Temp::tempdir(TMPDIR => 1, CLEANUP => 1); my $perlbin = "$tempdir/perl"; open my $ofh, ">> $perlbin" or die "Cannot write to $perlbin: $!"; print $ofh <<'EOF' or die $!; #! /bin/sh echo '#' echo '# Please use $^X instead of perl in system()' echo '# and similar calls.' echo '#' echo '# See also the $EXECUTABLE_NAME or $^X entry' echo '# in the perlvar.pod documentation.' echo '#' exit 1 EOF close $ofh or die $!; chmod 0755, $perlbin or die $!; $ENV{PATH} = "$tempdir:$ENV{PATH}"; # it's not MSDOS, so can use ":" } It is not turned on by default because they might be legitimate cases where "perl" is used, for example, if a part of the OS is using perl. Here's a report for such a case: http://rt.cpan.org/Public/Bug/Display.html?id=40162 Regards, Slaven -- Slaven Rezic - slaven <at> rezic <dot> de Berlin Perl Mongers - http://berlin.pm.org