remove temp. files from tests per default

used func. 'tempfile' instead of 'tmpnam' and added the possibility
to turn removing of temporary files on/off by setting a debug flag

Change-Id: Ib1ab2a66d92e2c4387faf17ac5738b6fab40582d
diff --git a/t/tei.t b/t/tei.t
index f9b5959..b602df6 100644
--- a/t/tei.t
+++ b/t/tei.t
@@ -8,9 +8,14 @@
   unshift @INC, "$FindBin::Bin/../lib";
 };
 
+our %ENV;
+# default: remove temp. file created by func. tempfile
+#  to keep temp. files use e.g. 'KORAPXMLTEI_DONTUNLINK=1 prove -lr t/script.t'
+my $_UNLINK = $ENV{KORAPXMLTEI_DONTUNLINK}?0:1;
+
 use_ok('KorAP::XML::TEI', 'remove_xml_comments');
 
-my ($fh, $filename) = tempfile();
+my ($fh, $filename) = tempfile("KorAP-XML-TEI_tei_XXXXXXXXXX", SUFFIX => ".tmp", TMPDIR => 1, UNLINK => $_UNLINK);
 
 print $fh <<'HTML';
 mehrzeiliger