#!/usr/bin/env perl use strict; use warnings; use 5.010; use Cwd (); use Fcntl (); use File::Temp qw(tempfile); my $pwd = Cwd::getcwd; say "pwd: $pwd"; my $template = 'somthing.XXXXXXX'; my $dir = '.'; my ($fh, $filename) = tempfile($template, DIR => $dir); say "filename: $filename"; system("ls -l '$filename'"); unlink $filename; system("ls -l '$filename'"); say "Now store 'Put some text in' in the file"; print $fh "Put some text in\n"; say "Written to file, try to read"; seek $fh, Fcntl::SEEK_SET, 0; while(my $line = <$fh>) { print "Found in file: $line"; } close $fh; say "End of prog";