> Hello
> 
> This does not work.
> 
>      `cp $srcfile $dstfile`; || do {
>       print "cannot copy $srcfile to $dstfile";
>     };
> 
> do is also execute if cp working fine. Whz is this so? The next thing I 
> would like to
> know how I can print the cp's error message.
> 
> Thanks
> 
> Urs

This isn't really a normal use of C<do>, you don't really need it at all
you can just use the C<||> or better C<or> to do the same thing.  The
reason that it is always executed is because the backticks are capturing
STDOUT, but the error is likely sent on STDERR. I would dispense with
the backticks completely, and switch to using the File::Copy module and
its C<copy> function.  It will be much more portable, and easier to
handle error conditions, more secure, etc.

perldoc File::Copy

http://danconia.org


-- 
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