my $tmp = File::Temp-> new( SUFFIX => '.ods' )-> filename; copyL 'whatever.ods', $tmp; say 'ok' if defined ReadData( $tmp ); #### copyL 'whatever.ods', my $tmp = File::Temp-> new( SUFFIX => '.ods' )-> filename; say 'ok' if defined ReadData( $tmp ); #### copyL 'whatever.ods', my $tmp = File::Temp-> new( SUFFIX => '.ods' ); say 'ok' if defined ReadData( $tmp-> filename ); #### use 5.014; use warnings; package Temp; use parent 'File::Temp'; sub new { my $self = shift; $self-> SUPER::new( DIR => '.' ) } sub DESTROY { my $self = shift; say 'global' if ${^GLOBAL_PHASE} eq 'DESTRUCT'; $self-> SUPER::DESTROY } package main; use File::Copy; sub foo { my $h = Temp-> new } die unless -f 'x'; # this file must exist copy 'x', my $fn1 = Temp-> new-> filename or die; copy 'x', my $fn2 = do { Temp-> new }-> filename or die; copy 'x', my $fn3 = do { my $h = Temp-> new }-> filename or die; copy 'x', my $fn4 = foo-> filename or die; say 1 if -f $fn1; say 2 if -f $fn2; say 3 if -f $fn3; say 4 if -f $fn4;