I can't believe I can't find this code. It *has* to be out there, right?
use Inline::TempFile;
my $temp_filename = Inline::Tempfile->new;
__DATA__
Everything here is written to that tempfile.
Basically, it would be nice for me to embed fixture data into a test that can
easily be written out to a file I can hand off to the code I'm testing. Right
now, I have to do stuff like this:
my $position = tell DATA;
my ($fh, $filename) = tempfile();
my $xml = do { local $/; <DATA> };
print $fh $xml;
close $fh;
seek( DATA, $position, 0 );
my $thing = Some::Module->new({xml_file => $filename});
__DATA__
<?xml version="1.0"?>
<items>
<item>
...
Is this module out there? I know it's trivial, but I hate to always rewrite
this code (admittedly the seek/tell stuff is rarely used). If it's not out
there, what should it be called? Inline::TempFile?
Cheers,
Ovid
--
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog - http://use.perl.org/~Ovid/journal/
Twitter - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6