Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: STDERR

by jettero (Monsignor)
on Dec 20, 2000 at 01:40 UTC ( [id://47472]=note: print w/replies, xml ) Need Help??


in reply to Re: STDERR
in thread STDERR

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: STDERR
by lemming (Priest) on Dec 20, 2000 at 01:48 UTC
    Actually, I did read the question. If you follow the threads in Getting STDERR to write to STDOUT? to Filehandle Filter. And there we see talk of tieing.
    Update: I realise I'm making you work for the answer and I didn't have anything better than what had been mentioned in those nodes.
    And... If you can read the filehandle, arrays are not a hurdle.

    One last link, because now I'll be stubborn about giving you the code. Filter::Handle by btrott

      Well, I obviously didn't ask the question very well, but your answer didn't help at all. Which is why I complained.

      Let me give it another shot.

      1. How do ya catch the messages from DBI without letting them get to the screen?
      2. How do ya store the lines of STDERR into an array.
      Linking to posts that show how to print STDERR to a file; how to tie a filehandle don't really help at all.

      I mean, in the big picture, ALL the questions I've ever seen posted in this section could be answered by reading the man pages. Near as I can tell there's only two reasons to post a question to perlmonks: 1) shortcut the research so you can have more fun programming, and 2) ask the question outloud so others can learn from your learning.

      So, if tieing a filehandle helps with populating my array some how, then I'd really appreaciate a hint; which is why I asked the question in the first place.

        I have a slight quibble with this (and because I wrote Filter::Handle :).

        A post that tells you how to tie a filehandle (or how to use Filter::Handle, or points you towards the existence of Filter::Handle, etc.) actually *should* help you to store prints to STDERR into an array. Try this:

        use Filter::Handle qw/subs/; my @errors; Filter \*STDERR, sub { push @errors, "@_"; () }; print STDERR "bar"; print STDERR "foo"; UnFilter \*STDERR;
        @errors now holds two elements: "bar" and "foo".

        If you read the Filter::Handle docs you'll find an example very much like this, under the head "Capturing Output".

        Note that this doesn't work for XS code, and it doesn't catch errors written by warn. So in that sense using $SIG{__WARN__} or working with DBI to get the errors back the way you want them is the right way to go.

        *However*, it's a useful technique to use, at times.

Re: Re: Re: STDERR
by qi3ber (Scribe) on Dec 20, 2000 at 02:18 UTC
    lemming is right. If you look far enough down the page on FileHandle Filter you will find a post describing how to send the output of a filehandle to a function, where you can append that data to your array. The pertinant information can be found at RE: Filehandle Filter.

    I hope that this can point you in the right direction.


       [ qi3ber ] I used to think that I knew it all, then I started to listen.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://47472]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-19 08:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found