Not to be rude, but as JWK said, "What doesn't work?" Also, mentioning the
Operating System would have been good.
Anyway, on the off-chance it's M$, I tried your script on this my Windows XP
Pro system, and got (with extra new lines):-
FILENAME:
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\KGxxRpbcuU\STARrequestaIscUR.xml <== From
your script
Can't unlink file
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\KGxxRpbcuU/STARrequestaIscUR.xml:
Permission denied at C:/Perl/lib/File/Temp.pm line 858
Can't remove directory C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\KGxxRpbcuU:
Directory not empty at C:/Perl/lib/File/Temp.pm line 858
After cleaning up a good deal of residual muck left over from a previous
exercise (thanks for the prompt!) relating to "read-only" and "hidden", I
found that (apparently by design, God help us) Windows leaves folders marked
"read only" even after changing all the files. Sure enough, the temporary
folder KGxxRpbcuU is so marked, and I'm guessing that might be your problem,
although the file has indeed been created, and the whole shooting match can
indeed be deleted manually.
If that's your problem, I have no idea how to solve it short of finding some
way to modify File::Temp and/or Windows. (Well, there's always using some
other OS...)
Sorry this isn't more helpful, rgds, GStC.
PS: also tried it on my ancient Linux RH 6.2 sys, but the Perl was 5_005,
and File::Temp was not installed. In any case, it is sensitive to Perl
level - I saw no point in going further.
----- Original Message -----
From: "Dave Adams" <[EMAIL PROTECTED]>
To: <beginners@perl.org>
Sent: Tuesday, July 05, 2005 4:53 PM
Subject: Problems Creating Temporary File
This code should work but it does not, any suggestions?
All I need is to create a temporary file to store some data so I can
stuff it into
another application and then trash it. I thought it would be easy.
use utf8;
use IO::Handle;
#use File::Copy;
use File::Temp qw /tempdir tempfile /;
$dir = tempdir (CLEANUP => 1);
($fh, $filename) = tempfile( DIR => $dir);
$template = "STARrequestXXXXXX";
($fh, $filename) = tempfile($template, DIR => $dir, SUFFIX => ".xml");
print "FILENAME: $filename\n";
#$fh->print("FILENAME: $filename\n");
$fh->print(" <?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
$fh->print(" <Root>\n");
$fh->print(" <GetSTARXMLInfo/>\n");
$fh->print(" <Quit/>\n");
$fh->print(" </Root>\n");
#copy($filename, "StarRequest.txt");
open (TEMPFILE , $filename) || die "Error: $!\n";
while(<TEMPFILE>) {
print $_;
}
$fh->close();
#sleep(10);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>