in reply to Re: (bbfu) Re: QuickPerl: a step up from -e
in thread QuickPerl: a step up from -e

So what will the exec do?!

I have no idea. :-p

Well, system is basically the same thing as fork/exec and my point was basically to do the STDERR redirect between the fork and the exec so that it wouldn't be (temporarily) redirected in the parent. I suppose that it's not really that big of a deal so you might as well just do:

# # Note: UNTESTED!!! # sub do_run { # write file... local *OLDERR, *NEWERR; open(OLDERR, ">& STDERR") or die "Can't dup STDERR: $!"; pipe(NEWERR, STDERR) or die "Can't pipe: $!"; system "perl quick_run.perl"; open(STDERR, ">& OLDERR") or die "Can't restore STDERR: $!"; my @error_lines = <NEWERR>; return @error_lines; }

bbfu
Seasons don't fear The Reaper.
Nor do the wind, the sun, and the rain.
We can be like they are.

Replies are listed 'Best First'.
Re: (bbfu) Re3: QuickPerl: a step up from -e
by John M. Dlugosz (Monsignor) on Jul 05, 2001 at 20:59 UTC
    I see your point on why it can be useful to separate the two, to do something in between. exec in ActiveState's port sais it will emulate it by starting a new process and then waiting for it to finish, then exiting with the same code itself. So it leaves the old program in memory!