On 08/01/2008 12:05 PM, Ovid 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.
>
> 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?
Personally, I'd say File::Temp::Inline or similar.
Although, it's such a small bit of code, IMO it barely justifies being a
seperate module:
my $fh = File::Temp->new;
$fh->printflush(do local $/; <DATA> });
my $thing = Some::Module->new({ file => $fh->filename });
Also, if it's test data that your test suite is going to pass to the
module in question, does it actually need to be stored inline within the
test script?
I think I'd prefer to just include it separately within the
distribution, rather than mixing up data + code. (Although you could
argue that the data is effectively part of the test).
Cheers
Dave P