in reply to print to data
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}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: print to data
by Yoda_Oz (Sexton) on Sep 06, 2006 at 12:15 UTC | |
by shmem (Chancellor) on Sep 06, 2006 at 14:12 UTC |