5 unshift @INC, '../lib';
8 # Test for File::Temp - POSIX functions
12 BEGIN { plan tests => 7}
14 use File::Temp qw/ :POSIX unlink0 /;
19 print "# TMPNAM: in a scalar context: \n";
20 my $tmpnam = tmpnam();
22 # simply check that the file does not exist
23 # Not a 100% water tight test though if another program
24 # has managed to create one in the meantime.
27 print "# TMPNAM file name: $tmpnam\n";
29 # TMPNAM array context
30 # Not strict posix behaviour
31 (my $fh, $tmpnam) = tmpnam();
33 print "# TMPNAM: in array context: $fh $tmpnam\n";
35 # File is opened - make sure it exists
39 ok( unlink0($fh, $tmpnam) );
46 print "# TMPFILE: tmpfile got FH $fh\n";
48 $fh->autoflush(1) if $] >= 5.006;
50 # print something to it
51 my $original = "Hello a test\n";
52 print "# TMPFILE: Wrote line: $original";
54 or die "Error printing to tempfile\n";
63 print "# TMPFILE: Read line: $line";
64 ok( $original, $line);