Open frioux opened 9 years ago
perl -E 'use IO::All; use Test::More; my $t =io->temp; $t->append("weezley"); is($t->slurp,"weezley", "text is there"); ok($t->filename, "has filename"); diag $t->name; done_testing;'
Feature seems to be AWOL.
@frioux, does this help you figure it out:
~/src/io-all-pm $ perl -Ilib -MXXX -MIO::All -E 'my $f = io->temp; $f->print("hello\n"); XXX $f'
--- !!perl/glob:IO::All::Temp
PACKAGE: Symbol
NAME: GEN0
HASH:
_autoclose: 0
_constructor: !!perl/code '{ "DUMMY" }'
_package: IO::All
io_handle: !!perl/glob:IO::File
PACKAGE: IO::File
NAME: _GEN_0
IO:
fileno: 3
stat:
device: 16777220
inode: 7808002
mode: 33152
links: 0
uid: 501
gid: 20
rdev: 0
size: 0
atime: 1452825166
mtime: 1452825166
ctime: 1452825166
blksize: 4096
blocks: 0
tell: 6
is_open: 1
...
at -e line 1
...
https://github.com/ingydotnet/io-all-pm/blob/master/lib/IO/All/Temp.pm#L9
my $temp_file = IO::File::new_tmpfile()
From https://metacpan.org/pod/IO::File
new_tmpfile
Creates an IO::File opened for read/write on a newly created temporary file. On systems where this is possible, the temporary file is anonymous (i.e. it is unlinked after creation, but held open). If the temporary file cannot be created or opened, the IO::File object is destroyed. Otherwise, it is returned to the caller.
If the file is anonymous, I would assume it has no name.
Can we close this, or should we do something different? What is your use case?
Ok I mentioned this on IRC but I might as well bring it up here; generally temp files are used for passing data to other programs. If for some reason you need to work with a filehandle but no file; it's even easier to just use io->string. With that support I see no reason for io->temp to work the way it does.
Right, my use case was passing a key file between openssl utils that don't accept stdin. I used File::Temp instead.
Where... is it?