If you need it restored within the sub itself, you can also throw
scoping brackets around it.  i.e. do what Paul suggested, only:

Sub func {
  # Some code here
  {
    open STDERR, ">$file" or die $!;
    # Code for the new STDERR here
  }
  # STDERR is back to normal here
  # More code
}

Remember, scoping brackets are you friend.  :o)

Brian Johnson
Partner/Systems Administrator/Programmer
Source1Hosting.tv, LLC (www.source1hosting.tv)
Source1Results.com, LLC (www.source1results.com)
I may be insane, but remember - The only
difference between an insane man and a
genius is his jacket.

> 
> --- Roland Schoenbaechler <[EMAIL PROTECTED]> wrote:
> > In a sub of my script I redirected STDERR in a file. How can I
> > redirect the STDERR back to the default (screen) for the following
> > subs?
> 
> Use local(). It's not something to make a big habit of, but this is a
> good place for it.
> 
>  sub func {
>     local *STDERR;
>     open STDERR, ">$file" or die $!;
>     # code here
>  }  # STDERR gets "fixed" when the local() scope ends here
> 
> c.f. perldoc -f local
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to