Re: How to handling string contains single quote and double quote
- From: vikrant <vikrant.kansal@xxxxxxxxx>
- Date: 28 Apr 2007 08:38:42 -0700
On Apr 28, 4:45 pm, j...@xxxxxxxxxxx (Jens Thoms Toerring) wrote:
vikrant <vikrant.kan...@xxxxxxxxx> wrote:
On Apr 28, 3:26 pm, Paul Lalli <mri...@xxxxxxxxx> wrote:
On Apr 28, 4:41 am, vikrant <vikrant.kan...@xxxxxxxxx> wrote:
system("echo '$Date;$String_Value' > data.txt");
Why are you calling a system command to do the echoing? Just open the
file for writing inPerl, and print the line to the file inPerl.
Then you don't have to worry about any escaping of quotes.
open my $fh, '>', 'data.txt' or die "Cannot open file: $!";
print $fh "$Date;$String_Value\n";
close $fh;
Paul LalliThanks for the information.Actually,the code is a part of a
function,which called again and again.So,i thought that opening and
closing a file on each call may effect the performance.That was the
only reason of using the system command.
Actually, your approach uses a lot more resources and time.
The system() function must create a new process, which in turn
executes a shell to deal with the command you sent to system().
And the file must be opened and closed again anyway, but now
the shell will do that. So all the system() call does is add
overhead, saving you nothing at all (beside making it harder
to check for errors).
Regards, Jens
--
\ Jens Thoms Toerring ___ j...@xxxxxxxxxxx
\__________________________ http://toerring.de
Hi JensThoms,
Thanks for sharing the information.It is very helpful to me.
Regards,
Vikrant
.
- References:
- How to handling string contains single quote and double quote
- From: vikrant
- Re: How to handling string contains single quote and double quote
- From: Paul Lalli
- Re: How to handling string contains single quote and double quote
- From: vikrant
- Re: How to handling string contains single quote and double quote
- From: Jens Thoms Toerring
- How to handling string contains single quote and double quote
- Prev by Date: Can a network client specify an IP on the source side?
- Next by Date: perl newbie
- Previous by thread: Re: How to handling string contains single quote and double quote
- Next by thread: FAQ 4.33 How do I pad a string with blanks or pad a number with zeroes?
- Index(es):