dagolden / Path-Tiny

File path utility
41 stars 59 forks source link

tempfile example does not work as expected #247

Closed robrwo closed 1 year ago

robrwo commented 2 years ago

in the POD it lists a possible way of calling tempfile as and tempdir

$temp = $dirpath->tempfile( @options );
$temp = $dirpath->tempdir( @options );

I would expect something like

$temp = $dirpath->tempfile( @options );

to be the equivalent of

File::Temp->new( DIR => $dirpath->stringify, @options );
xdg commented 1 year ago

Can you give runnable example that shows the way it's not meeting your expectation?

I ran this sample program:

use v5.28;
use strict;
use warnings;

use Path::Tiny;

my $cwd=path(".")->absolute;

my $tempfile = $cwd->tempfile( "fileXXXXXX");
my $tempdir = $cwd->tempdir( "dirXXXXXX");

say "base: " . $cwd;
say "file: " . $tempfile;
say "dir: " . $tempdir;

And got this output:

base: /home/xdg/tmp/path-tiny-tmp
file: /home/xdg/tmp/path-tiny-tmp/file89x6sQ
dir: /home/xdg/tmp/path-tiny-tmp/dir71xAob
robrwo commented 1 year ago

Hm. I'm not sure where I ran into problems that led me to create this ticket. I'm closing it.