status of redirecting STDOUT/STDERR to file

J

jonathan

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";
 
A

Anno Siegel

jonathan said:
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
 
J

jonathan

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
 
A

Anno Siegel

jonathan said:
(e-mail address removed)-berlin.de (Anno Siegel) wrote in message


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
 
S

Sam Holden

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.
 
T

Tad McClellan

jonathan said:
(e-mail address removed)-berlin.de (Anno Siegel) wrote in message


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.
 
J

Jay Tilton

(e-mail address removed) (jonathan) wrote:

: (e-mail address removed)-berlin.de (Anno Siegel) wrote in message : > > 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top