1 #!/usr/local/bin/perl -w
2 # Test for File::Temp - POSIX functions
6 BEGIN { plan tests => 7}
8 use File::Temp qw/ :POSIX unlink0 /;
14 print "# TMPNAM: in a scalar context: \n";
15 my $tmpnam = tmpnam();
17 # simply check that the file does not exist
18 # Not a 100% water tight test though if another program
19 # has managed to create one in the meantime.
22 print "# TMPNAM file name: $tmpnam\n";
25 # Not strict posix behaviour
26 (my $fh, $tmpnam) = tmpnam();
28 print "# TMPNAM: in list context: $fh $tmpnam\n";
30 # File is opened - make sure it exists
33 # Unlink it - a possible NFS issue again if TMPDIR is not a local disk
34 my $status = unlink0($fh, $tmpnam);
38 skip("Skip test failed probably due to \$TMPDIR being on NFS",1);
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";
63 print "# TMPFILE: Read line: $line";
64 ok( $original, $line);
69 # Skip all the remaining tests
71 skip("Skip test failed probably due to \$TMPDIR being on NFS",1);