Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Re: Re: Best Way to Redirect STDERR to a Scalar

by Mr. Muskrat (Abbot)
on Sep 14, 2003 at 02:14 UTC ( #291334=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Best Way to Redirect STDERR to a Scalar
in thread Best Way to Redirect STDERR to a Scalar

I really thought this would do it but it did not. :-(

use IO::Scalar; use Devel::Peek; print STDERR " STDERR test (1)\n"; my $io = ioscalar(); print STDERR " STDERR test (3)\n"; printf " Scalar string has length %d\n", length($io); printf " and contains '%s'\n", $io; print STDERR " STDERR test (4)\n"; my $peek = peek(); print STDERR " STDERR test (5)\n"; printf " Scalar string has length %d\n", length($peek); printf " and contains '%s'\n", $peek; sub ioscalar { my $data; tie *STDERR, 'IO::Scalar', \$data; print STDERR " STDERR test (2)\n"; untie *STDERR; return $data; } sub peek { my $data; my $test = 'string'; tie *STDERR, 'IO::Scalar', \$data; Dump($test); untie *STDERR; return $data; } __DATA__ STDERR test (1) STDERR test (3) Scalar string has length 17 and contains ' STDERR test (2) ' STDERR test (4) SV = PV(0x177eb58) at 0x1cbc540 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x1773c74 "string"\0 CUR = 6 LEN = 7 STDERR test (5) Scalar string has length 0 and contains ''


Comment on Re: Re: Re: Best Way to Redirect STDERR to a Scalar
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-12-17 23:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (40 votes), past polls