Re: Env::Reject

2001-01-31 Thread Chris Nandor

At 21:34 -0500 01.30.2001, David Boyce wrote:
I just threw together a little module currently named Env::Reject and would
like a review of the name and concept. In particular, if there's a
different/better solution than re-execing with a depleted environment I'd
appreciate hearing about it. I'll just paste in the relevant POD sections
below.

I've never really thought about this before, but it is an interesting
problem and solution.  What are the issues involved in "re-executing" a
script?  How is that re-execution done?

-- 
Chris Nandor  [EMAIL PROTECTED]http://pudge.net/
Open Source Development Network[EMAIL PROTECTED] http://osdn.com/



Re: Env::Reject

2001-01-31 Thread John Porter

David Boyce wrote:
  How is that re-execution done?
 
 On UNIX it's straightforward: "exec $^X ,$0, @ARGV" out of a BEGIN clause. 
 On Windows I do "exit system $^X ,$0, @ARGV", 

Huh?  exec() works!  At least on some versions of Windows.


 though since Perl's system() 
 always exposes its argument to the shell...

Are you sure that's a fact on Windows?
It's definitely not true for unix.
The docs for exec() clearly state this.


-- 
John Porter

So take a pointed stick and touch Piggy's eyes
He's gonna turn and leave you a big surprise




Re: Env::Reject

2001-01-31 Thread Chris Nandor

At 11:00 -0500 01.31.2001, David Boyce wrote:
At 07:50 AM 1/31/01 -0500, Chris Nandor wrote:

I've never really thought about this before, but it is an interesting
problem and solution.  What are the issues involved in "re-executing" a
script?  How is that re-execution done?

On UNIX it's straightforward: "exec $^X ,$0, @ARGV" out of a BEGIN clause.
On Windows I do "exit system $^X ,$0, @ARGV", though since Perl's system()
always exposes its argument to the shell it's necessary to do some quoting
first and as a corollary there are probably some pathological cmdlines for
which it will fail. I've only attempted to address UNIX and Windows so far
(I only wrote it last night!) but will probably put in a check to fail
gracefully on the Mac, or would gladly accept a patch to make it work there.

Does this method work OK for mod_perl scripts, etc.?

As to working on a Mac: I am not sure what the best thing to do would be.
It'd probably really need to be some deep voodoo, since there is no exec(),
and system() calls from the application out to the command line tool, which
might not be what you want.  I am sure it can be done, but it would likely
need a patch to MacPerl itself in order to get it work, unless there's
something I am not thinking of.  But then again, this is not something
really needed on a Mac at this point, that I can think of, so I wouldn't
worry about it.  :-)


I guess I should document that Env::Reject should be the first module use'd
so no other BEGIN gets in there and does real work before the re-exec.

That'd probably be a good idea, yeah.  Unless you _like_ to get the same
question asked of you over and over ... :)

-- 
Chris Nandor  [EMAIL PROTECTED]http://pudge.net/
Open Source Development Network[EMAIL PROTECTED] http://osdn.com/



Re: Env::Reject

2001-01-31 Thread Nicholas Clark

 At 11:00 -0500 01.31.2001, David Boyce wrote:

 On UNIX it's straightforward: "exec $^X ,$0, @ARGV" out of a BEGIN clause.

Linux isn't UNIX:

$ cat argv.pl
#!/usr/bin/perl -w
print "$^X\n";
print "$0\n";

$ ./argv.pl 
perl
./argv.pl

where's perl? :-(

[and anyone who assumes that perl is the first perl in my $PATH
(eg http://jarl.sourceforge.net/) does not please me]

I think that's going to be "interesting" for the rare case where the script
comes in on stdin.

Nicholas Clark