in reply to HTML::TreeBuilder. Redirect tree->dump to an array
It is unclear what you are trying to do but making the assumption that the dump method will only write to a file handle and would like to avoid a temp file just use an IO::String object where you have *OUT. Dump will then happily dump into this. This is what IO::String was designed for.
use IO::String; my $io = IO::String->new; $tree->dump($io); $io->setpos(0); @lines = <$io>; # dump output in an array
About the only gotcha with IO::String objects is that if you write to one you end up at EOF (end of string) so in order to read all the data in you need to seek back to the begining (pos, setpos and seek all work). If you forget to do this it appears there is no data.....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: HTML::TreeBuilder. Redirect tree->dump to an array
by mm&mm (Initiate) on May 05, 2008 at 11:11 UTC |