Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   status of redirecting STDOUT/STDERR to file (http://www.velocityreviews.com/forums/t883773-status-of-redirecting-stdout-stderr-to-file.html)

jonathan 11-20-2003 08:48 PM

status of redirecting STDOUT/STDERR to file
 
hey all,

just curious, but if I do the following (after __cut__), does this
have any repercussions for the 'regular' STDERR, STDOUT handles?

jon

__cut__
sub redirect
{
local(*STDERR);
local(*STDOUT) = *STDERR;
open(STDERR, "> /tmp/logit");

print STDERR "HERE!!!\n";
print STDERR "HEREA!!!\n";

close(STDERR);
}

redirect();

print STDERR "HEREB!!!\n";
print STDOUT "HEREC!!!\n";

Anno Siegel 11-21-2003 09:28 AM

Re: status of redirecting STDOUT/STDERR to file
 
jonathan <ttyp32000@yahoo.com> wrote in comp.lang.perl.misc:
> hey all,
>
> just curious, but if I do the following (after __cut__), does this
> have any repercussions for the 'regular' STDERR, STDOUT handles?


It shouldn't.

Why are you dealing with STDOUT in redirect()? You're not using it in
any way.

> __cut__
> sub redirect
> {
> local(*STDERR);
> local(*STDOUT) = *STDERR;

^^^^^^^^^^^^^^^^^^^^^^^^
This does nothing useful.

> open(STDERR, "> /tmp/logit");
>
> print STDERR "HERE!!!\n";
> print STDERR "HEREA!!!\n";
>
> close(STDERR);
> }
>
> redirect();
>
> print STDERR "HEREB!!!\n";
> print STDOUT "HEREC!!!\n";


Anno

jonathan 11-24-2003 06:46 PM

Re: status of redirecting STDOUT/STDERR to file
 
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<bpklsj$da3$1@mamenchi.zrz.TU-Berlin.DE>...
> jonathan <ttyp32000@yahoo.com> wrote in comp.lang.perl.misc:
> > hey all,
> >
> > just curious, but if I do the following (after __cut__), does this
> > have any repercussions for the 'regular' STDERR, STDOUT handles?

>
> It shouldn't.
>
> Why are you dealing with STDOUT in redirect()? You're not using it in
> any way.


its called a *typo*. read:

print STDOUT "HERE!!!\n";
print STDERR "HEREA!!!!\n";

I appreciate the help, but the attitude could be a little less snide.
The code snippet was designed to show whether or not any effects might
happen outside of the subroutine.

jon

Anno Siegel 11-24-2003 09:07 PM

Re: status of redirecting STDOUT/STDERR to file
 
jonathan <ttyp32000@yahoo.com> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> news:<bpklsj$da3$1@mamenchi.zrz.TU-Berlin.DE>...
> > jonathan <ttyp32000@yahoo.com> wrote in comp.lang.perl.misc:
> > > hey all,
> > >
> > > just curious, but if I do the following (after __cut__), does this
> > > have any repercussions for the 'regular' STDERR, STDOUT handles?

> >
> > It shouldn't.
> >
> > Why are you dealing with STDOUT in redirect()? You're not using it in
> > any way.

>
> its called a *typo*. read:


Well, typos in code aren't exactly trivial, whether in communicating with
the machine or with other programmers. It made the meaning of your
extensive question "any repercussions" even harder to grasp.

> print STDOUT "HERE!!!\n";
> print STDERR "HEREA!!!!\n";
>
> I appreciate the help, but the attitude could be a little less snide.
> The code snippet was designed to show whether or not any effects might
> happen outside of the subroutine.


Short and to the point, yes. Snide, no.

Anno

Sam Holden 11-24-2003 09:24 PM

Re: status of redirecting STDOUT/STDERR to file
 
On 24 Nov 2003 10:46:56 -0800, jonathan <ttyp32000@yahoo.com> wrote:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<bpklsj$da3$1@mamenchi.zrz.TU-Berlin.DE>...
>> jonathan <ttyp32000@yahoo.com> wrote in comp.lang.perl.misc:
>> > hey all,
>> >
>> > just curious, but if I do the following (after __cut__), does this
>> > have any repercussions for the 'regular' STDERR, STDOUT handles?

>>
>> It shouldn't.
>>
>> Why are you dealing with STDOUT in redirect()? You're not using it in
>> any way.

>
> its called a *typo*. read:
>
> print STDOUT "HERE!!!\n";
> print STDERR "HEREA!!!!\n";
>
> I appreciate the help, but the attitude could be a little less snide.
> The code snippet was designed to show whether or not any effects might
> happen outside of the subroutine.


Your failure to read the posting guidelines that are posted here a lot, or
even worse failure to follow them after reading them, combined with that
post will I suspect greatly reduce the useful answers you get in future.

--
Sam Holden

Tad McClellan 11-24-2003 10:01 PM

Re: status of redirecting STDOUT/STDERR to file
 
jonathan <ttyp32000@yahoo.com> wrote:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<bpklsj$da3$1@mamenchi.zrz.TU-Berlin.DE>...



>> Why are you dealing with STDOUT in redirect()? You're not using it in
>> any way.

>
> its called a *typo*.



Do not re-type Perl code

Use copy/paste or your editor's "import" function rather than
attempting to type in your code. If you make a typo you will get
followups about your typos instead of about the question you are
trying to get answered.


Somebody ought to write these things down somewhere...


> I appreciate the help, but the attitude could be a little less snide.



If you had been more considerate of other's time, there would have
been no reaping what you had sown.


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas

Jay Tilton 11-25-2003 12:58 AM

Re: status of redirecting STDOUT/STDERR to file
 
ttyp32000@yahoo.com (jonathan) wrote:

: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<bpklsj$da3$1@mamenchi.zrz.TU-Berlin.DE>...
: > jonathan <ttyp32000@yahoo.com> wrote in comp.lang.perl.misc:
: > > hey all,
: > >
: > > just curious, but if I do the following (after __cut__), does this
: > > have any repercussions for the 'regular' STDERR, STDOUT handles?
: >
: > It shouldn't.
: >
: > Why are you dealing with STDOUT in redirect()? You're not using it in
: > any way.

: I appreciate the help, but the attitude could be a little less snide.

There was nothing in the article that betrayed any attitude, snide or
otherwise.

Pointing out that localizing the STDOUT filehandle has no useful effect
because it is never used in that dynamic scope was actually a partial
answer to the question.

: The code snippet was designed to show whether or not any effects might
: happen outside of the subroutine.

It depends on what is meant by "outside."

Outside of the sub's lexical scope but still within the typeglob's
localized dynamic scope, yes.

Outside of the typeglob's dynamic scope, i.e. when the subroutine exits,
no.



All times are GMT. The time now is 07:29 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.