Subject: | slurp from overloaded File::Temp handle |
Date: | Sat, 09 Feb 2013 07:09:11 +1100 |
To: | bug-Perl6-Slurp [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
With Perl6::Slurp 0.051001 and File::Temp 0.22 in recent debian perl
5.14.2, the program filetemp.pl below gets a warning
Argument "/z/tmp/wsWtWhi3GT" isn't numeric in numeric eq (==) at /usr/share/perl5/Perl6/Slurp.pm line 176.
I believe this is due to File::Temp not having a numize. David Golden's
advice is to compare handles with refaddr. I think File::Temp could
helpfully have numize or == or both, but comparing with refaddr would
work too and might catch other overloaded handles without a numize, or
with some overly creative numize. The aim in Perl6::Slurp is just to
notice when the handle is \*ARGV I take it.
use strict;
use Perl6::Slurp 'slurp';
use File::Temp;
my $fh = File::Temp->new;
my $str = slurp $fh;