2 # Test for File::Temp - POSIX functions
6 unshift @INC, '../lib';
7 require Test; import Test;
13 use File::Temp qw/ :POSIX unlink0 /;
18 print "# TMPNAM: in a scalar context: \n";
19 my $tmpnam = tmpnam();
21 # simply check that the file does not exist
22 # Not a 100% water tight test though if another program
23 # has managed to create one in the meantime.
26 print "# TMPNAM file name: $tmpnam\n";
29 # Not strict posix behaviour
30 (my $fh, $tmpnam) = tmpnam();
32 print "# TMPNAM: in list context: $fh $tmpnam\n";
34 # File is opened - make sure it exists
38 ok( unlink0($fh, $tmpnam) );
45 print "# TMPFILE: tmpfile got FH $fh\n";
47 $fh->autoflush(1) if $] >= 5.006;
49 # print something to it
50 my $original = "Hello a test\n";
51 print "# TMPFILE: Wrote line: $original";
53 or die "Error printing to tempfile\n";
62 print "# TMPFILE: Read line: $line";
63 ok( $original, $line);