use Path::Tiny qw/ path /; path( $logfile1 )->spew( @output1 ); path( $logfile2 )->spew( @output2 ); path( $logfile3 )->spew( @output3 );