in reply to Need Help: Capture Print Outputs from a Function
Output:#!/usr/bin/perl use strict; use warnings; my ($buf); { local *STDOUT; open( STDOUT, '>', \$buf ) or die "Write to buffer failed\n"; mysub(); } print "buffer: $buf\n"; sub mysub{ print "mysub output\n"; }
Does that help?---------- Capture Output ---------- > "C:\Perl\bin\perl.exe" _new.pl buffer: mysub output > Terminated with exit code 0.
Update: The above requires 5.8 (thanks to ikegami for pointing that out).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need Help: Capture Print Outputs from a Function
by mnj200g (Novice) on May 02, 2006 at 18:05 UTC | |
by ikegami (Patriarch) on May 02, 2006 at 18:19 UTC | |
by wfsp (Abbot) on May 02, 2006 at 18:22 UTC | |
by mnj200g (Novice) on May 02, 2006 at 18:58 UTC | |
|
Re^2: Need Help: Capture Print Outputs from a Function
by mnj200g (Novice) on May 03, 2006 at 01:01 UTC |