Hi Ron,

Thank you very very much,

-Mahdi.


Rob Dixon wrote:

Mahdi A Sbeih wrote:
>
> I am using the below code:
>
> $fmtFile = `$dpImportCmd`;
> ..
> ..
> unlink($fmtFile) || die "unable to remove $fmtFile\n";
>
>
> dpImportCmd, is a program that generates a text file, this text file
> name is now in the variable: $fmtFile. Later in the program, I want to
> delete this file, but it fails. I don't know why.
>
> In the perl cookbook, it says "The backticks do not return until the
> called program exits"
>
> Is this related?

The book means that backticks don't return /control/ until the comand is
complete. That means that your Perl program is suspended until then and can't go on to execute the unlink() until everything's finished. So no, that's not your
problem.

What is likely to be wrong is that dpImportCmd tags a newline onto the end of its
output, which is then an invalid filename and cannot be used in a call to
unlink(). Things will probably come together if jou just do chomp($fmtFile) first, but /please/ check carefully the contents of your string before you just go ahead and do this as there may be leading whitespace or even multi-line output. An easy way to see non-printables in a string is to use URI::Escape if
you have the module installed.

  use URI::Escape;
  print uri_escape "  abc\n\n";

outputs

  %20%20abc.txt%0A%0A

so

  use URI::Escape;
  print uri_escape $fmtFile;

will show you what is hiding in your string variable.

HTH,

Rob


--







Best Regards,
Mahdi Sbeih
PDF Solutions - www.pdf.com
Tel : 1 408 216 8646 ( VoIP in Jerusalem )
Cell: +972-52-5674155

_____________________________________________________________________
CONFIDENTIALITY NOTICE: This e-mail contains information that may
be confidential and privileged. Unless you are the intended recipient
(or authorized to receive for the intended recipient), you are
prohibited from reviewing, using, copying, forwarding, keeping,
or disclosing to anyone other than PDF Solutions, Inc. this e-mail
or any information in the e-mail (including any attachment). If you
have received this e-mail in error, please send a reply e-mail only to
the sender ([EMAIL PROTECTED]) (deleting the original message body
from the reply), and please delete this message from your system.
My apologies for the inconvenience, and thank you in advance for your
cooperation.
_____________________________________________________________________


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to