Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I delete a temp file that I create in PERL?

Status
Not open for further replies.

mheilbut

Programmer
Apr 24, 2002
53
BR
This is the command line that creates a temp file:

$exit = system("/usr/progs/fatrep.pl $repre $data $datb >/tmp/".$repre."fatrep1.html");

After this I use metasend and I send an e-mail for my client.
I would like to after using the metasend delete the temp I created.
How can I do this? Michel, São Paulo, Brazil
 
unlink('/path/to/file.ext'); Mike
________________________________________________________________________________

"Experience is the comb that Nature gives us, after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
It didn't work correctly.
It didn't give me an error message but it continued with my temp file.

The commands are as follows:

$exit = system("/usr/progs/pedrep.pl $repre $data $datb >/tmp/".$repre."pedrep1.html");
$exit = system("metasend -b -t $email -s 'Pedidos' -f /tmp/".$repre."pedrep1.html -m text/html -S 500$
unlink('/tmp/to/".$repre."pedrep1.html');

Any thoughts? thanx Michel, São Paulo, Brazil
 
ah yes..

if you use single quotes to start and end a string, perl won't evaluate any variables in that string.

try this, the variable is not quoted at all here:

unlink('/tmp/to/' . $repre . 'pedrep1.html');
Mike
________________________________________________________________________________

"Experience is the comb that Nature gives us, after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
The pedrep2.pl program executes fine but when I enter the tmp directory, the file is still there.
Any other sugestions?
Thanks. Michel, São Paulo, Brazil
 
print "/tmp/to/".$repre."pedrep1.html";

Make sure that this is a valid filename. If nothing is getting deleted, the most probably cause is that the file you are trying to delete isn't actually the one you specifiy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top