> I want to use the unlink command to programmatically delete files.
>
> I have modified this code snippet but it no longer works, I
> suspect that it's because unlink returns the number of deleted files.
>
> my $cmd = qq[unlink $srcFile];
> $debug->printlog("command: $cmd");
> my $cmdResult = `$cmd 2>&1`;
> $debug->printlog("result: $cmdResult");
...
>
> So want Im trying to achieve is delete file Write the
> successful deletion or error to the log file then continue.
> But it executes the else clause each time.
why are you trying to assign the command to a variable, and why are you
using backtics to call it?
simply try:
$cnt = unlink $srcFile;
$result = $cnt ? "Deleted $cnt files" : "error";
$debug->printlog("result: $result");
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.796 / Virus Database: 540 - Release Date: 11/13/2004
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>