Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io->temp seems broken #80

Open
frioux opened this issue Apr 1, 2015 · 5 comments
Open

io->temp seems broken #80

frioux opened this issue Apr 1, 2015 · 5 comments

Comments

@frioux
Copy link
Collaborator

frioux commented Apr 1, 2015

  my $f = io->temp;
  $f->print("foo");
  warn $f->name;

Where... is it?

@wesQ3
Copy link

wesQ3 commented Jan 13, 2016

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.

@ingydotnet
Copy link
Owner

@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
...

@ingydotnet
Copy link
Owner

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?

@frioux
Copy link
Collaborator Author

frioux commented Jan 15, 2016

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.

@wesQ3
Copy link

wesQ3 commented Jan 15, 2016

Right, my use case was passing a key file between openssl utils that don't accept stdin. I used File::Temp instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants