in reply to Re^2: Problems with Filehandles and TeeOutput
in thread Problems with Filehandles and TeeOutput

I couldn't help but notice that you used
#Does not work open(my $fh, '>>', 'test.out'); openTee(*STDOUT, *STDOUT, *$fh);
instead of
#Should be working open(my $fh, '>>', 'test.out'); openTee(*STDOUT, *STDOUT, $fh); #asterisks ONLY before STDOUT, NOT $fh
would you mind testing once more?
[]s, HTH, Massa (κς,πμ,πλ)

Replies are listed 'Best First'.
Re^4: Problems with Filehandles and TeeOutput
by ikegami (Patriarch) on Aug 26, 2008 at 17:27 UTC

    That was intentional. It definitely won't work without the asterisk because the module expects a glob, not a reference to one.

    >perl -le"open(my $fh,'>','foo'); print( (ref(\$fh) eq 'GLOB') ?1:0)" 0

    That needs to be 1 or that module will stringify the handle.

Re^4: Problems with Filehandles and TeeOutput
by hkpatv (Initiate) on Aug 27, 2008 at 01:33 UTC
    Tested, still not working.
    #!/usr/bin/perl -w use Local::TeeOutput; use strict; #No, still not working... open(my $fh, '>>', 'test2.out'); openTee(*STDOUT, *STDOUT, $fh); print "XX\n"; close($fh);
    Note it creates a file called GLOB(0x239bcc) which contains the correct data. Note I have been further reading simlar threads on perlmonks and elsewhere for what I am actually trying to do (write STDERR to file and save as variable). The solutions I have found are very complicated and work only on Unix (mine needs to be windows and unix compatible). Coming to the conclusion that the solution, if it exists will be take considerable effort which is likely not worthwile. I was hoping TeeOutput would be a quick solution, but it looks like it won't be suitable.