Gidday All,

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");
    my $cmd = qq[$IWREGEN "$file"];
    my $cmdResult = `$cmd 2>&1`;
    if ($cmdResult =~ /^\s*$/) {
      $cmdResult = "Successful file regeneration." if ($cmdResult =~
/^\s*$/); 
      $comment = "REGEN COMMAND: $cmd\nREGEN RESULT: $cmdResult";
      $debug->printlog("REGEN $pid: Regen " . &basename($file) .
"\n$comment");   
    } else {
      $errorComment = "ERROR: " . &basename($file) . " renegeneration
failed:\n";
      $errorComment .= "  Cmd: $cmd\n    Result: $cmdResult\n";
      $debug->printlog("$errorComment");
      &abort(1, "$errorComment");
    }

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.

Regards
Colin

Colin Johnstone 
Interwoven Teamsite Analyst Programmer 
eGovernment Delivery Team
QLD Department of Employment and Training
Telephone (07) 3244 6281
Fax (07) 3244 6265
Address Southbank Institute of TAFE - Kangaroo Point Campus
Visit: http://www.trainandemploy.qld.gov.au/ 



This E-Mail is intended only for the addressee. Its use is limited to that
intended by the author at the time and it is not to be distributed without the
author's consent. Unless otherwise stated, the State of Queensland accepts no
liability for the contents of this E-Mail except where subsequently confirmed in
writing. The opinions expressed in this E-Mail are those of the author and do
not necessarily represent the views of the State of Queensland. This E-Mail is
confidential and may be subject to a claim of legal privilege.

If you have received this E-Mail in error, please notify the author and delete 
this message immediately.

Reply via email to