I have my own unpublished version of that kind of thing that I keep
meaning to release as an Archive::* module -- where a .pm file with a
DATA section is the archive, including the code necessary to unpack
it. And supporting multiple files, of course.
It's been languishing for lack of tuits.
David
On Fri, Aug 1, 2008 at 7:05 AM, Ovid
<[EMAIL PROTECTED]> wrote:
> 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
>