status of redirecting STDOUT/STDERR to file

Discussion in 'Perl Misc' started by jonathan, Nov 20, 2003.

  1. jonathan

    jonathan Guest

    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";
    jonathan, Nov 20, 2003
    #1
    1. Advertising

  2. jonathan

    Anno Siegel Guest

    jonathan <> 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
    Anno Siegel, Nov 21, 2003
    #2
    1. Advertising

  3. jonathan

    jonathan Guest

    -berlin.de (Anno Siegel) wrote in message news:<bpklsj$da3$-Berlin.DE>...
    > jonathan <> 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
    jonathan, Nov 24, 2003
    #3
  4. jonathan

    Anno Siegel Guest

    jonathan <> wrote in comp.lang.perl.misc:
    > -berlin.de (Anno Siegel) wrote in message
    > news:<bpklsj$da3$-Berlin.DE>...
    > > jonathan <> 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
    Anno Siegel, Nov 24, 2003
    #4
  5. jonathan

    Sam Holden Guest

    On 24 Nov 2003 10:46:56 -0800, jonathan <> wrote:
    > -berlin.de (Anno Siegel) wrote in message news:<bpklsj$da3$-Berlin.DE>...
    >> jonathan <> 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
    Sam Holden, Nov 24, 2003
    #5
  6. jonathan <> wrote:
    > -berlin.de (Anno Siegel) wrote in message news:<bpklsj$da3$-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
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Nov 24, 2003
    #6
  7. jonathan

    Jay Tilton Guest

    (jonathan) wrote:

    : -berlin.de (Anno Siegel) wrote in message news:<bpklsj$da3$-Berlin.DE>...
    : > jonathan <> 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.
    Jay Tilton, Nov 25, 2003
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon Landenburer

    redirecting stderr and stdout

    Jon Landenburer, May 12, 2004, in forum: Perl
    Replies:
    1
    Views:
    11,204
    Joe Smith
    May 13, 2004
  2. Jan Knop
    Replies:
    4
    Views:
    1,033
    Jan knob
    Nov 24, 2003
  3. Michael McGarry
    Replies:
    1
    Views:
    606
    Michael Fuhr
    Dec 16, 2004
  4. Lincoln Yeoh

    Redirecting stderr and stdout to syslog

    Lincoln Yeoh, Aug 5, 2008, in forum: Python
    Replies:
    2
    Views:
    2,119
    Lincoln Yeoh
    Aug 6, 2008
  5. it_says_BALLS_on_your forehead
    Replies:
    2
    Views:
    263
    Joe Smith
    Jan 10, 2006
Loading...

Share This Page