I get the following message: Use of uninitialized value in concatenation (.)
You're using a version of Perl older than 5.8.0, when open(STDOUT, '>', \$buf) was introduced. Before 5.8, \$buf would be stringified to something like SCALAR(0x1ab2760). The output ends up in a file by that name instead of going to $buf, so $buf is still undefined when you go to inspect it.
Before 5.8, you had to use IO::String or IO::Scalar.
Also, what is the structure under my ($buf); in your code?
It creates a new scope. This causes local *STDOUT; to be undone (thus restoring the original STDOUT) before the last print.
what is the significant of "qw"
qw[ some args here ]
is the same thing as
('some', 'args', 'here')
See perlop.
In reply to Re^3: Need Help: Capture Print Outputs from a Function
by ikegami
in thread Need Help: Capture Print Outputs from a Function
by mnj200g
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |