2 # Test for File::Temp - POSIX functions
7 require Test; import Test;
13 use File::Temp qw/ :POSIX unlink0 /;
20 print "# TMPNAM: in a scalar context: \n";
21 my $tmpnam = tmpnam();
23 # simply check that the file does not exist
24 # Not a 100% water tight test though if another program
25 # has managed to create one in the meantime.
28 print "# TMPNAM file name: $tmpnam\n";
31 # Not strict posix behaviour
32 (my $fh, $tmpnam) = tmpnam();
34 print "# TMPNAM: in list context: $fh $tmpnam\n";
36 # File is opened - make sure it exists
40 ok( unlink0($fh, $tmpnam) );
47 print "# TMPFILE: tmpfile got FH $fh\n";
49 $fh->autoflush(1) if $] >= 5.006;
51 # print something to it
52 my $original = "Hello a test\n";
53 print "# TMPFILE: Wrote line: $original";
55 or die "Error printing to tempfile\n";
64 print "# TMPFILE: Read line: $line";
65 ok( $original, $line);