and change all your print statements to cprint. Setting $capture to 1 results in filling the array @output.# set up an array at the top of your program my @output; # set up a flag my $capture = 0; sub cprint { $capture ? (print @_) : push(@output,@_); }
Another hint: Don't use - even for quick hacks - the DATA filehandle for regular files, the DATA filehandle is special. See e.g. perldata.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In reply to Re: print to data
by shmem
in thread print to data
by Yoda_Oz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |