SPUG: redirect close

ced at carios2.ca.boeing.com ced at carios2.ca.boeing.com
Mon Aug 26 12:59:39 CDT 2002


> I'm maintaining a program where I constantly see
>         2>&1

> which I believe redirects STDOUT to STDIN, but regardless of what exactly it
> does I'm aware its a redirect of some kind and I would really like to know
> its scope for declaration and how to cut it off.  Is it limited to the block
> it is declared in, or does this type of command continue to live on outside
> of a give code block.

2>&1 redirects STDERR to STDOUT and persists while the filehandle
is open.

The redirection scopes to the life of the open filehandle.
The only loophole occurs when the filehandle is localized, eg,

   {  local *STDERR;
      open (STDERR, ">&SOME_OTHER_FILEHANDLE") or die "can't dup: $!"; 
      ...
   }
   
I think some of the online docs discuss redirection. 

Hope this helps,
--
Charles DeRykus

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




More information about the spug-list mailing list