Perl script

Perl script

am 25.07.2006 07:03:03 von asingh4

------_=_NextPart_001_01C6AFA7.9BCDBBF1
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi All,

This is my first email to the group and I hope that I landed in the
correct place.

=20

Ok now coming to the problem. Can someone explain to me that what this
script is doing. I want to know the meaning of all the lines in the
script.

=20

$val =3D defined $val ? $val : "null";

$val =3D~ s/\'/$& x 2/eg; # double pad single
quote character '

=20

Please help me out understand the meaning of the lines above.

=20

With Regards,

=20

Amar P Singh

desk: +91 124 4167037

mobile: +91 (0) 9810788298=20
e-mail: asingh4@sapient.com

=20


------_=_NextPart_001_01C6AFA7.9BCDBBF1--

RE: Perl script

am 25.07.2006 10:48:57 von Martin.Evans

This is not the correct list for this question - this list is for Perl DBI
users. Try http://lists.cpan.org/showlist.cgi?name=beginners.

Martin
--
Martin J. Evans
Easysoft Ltd, UK
http://www.easysoft.com


On 25-Jul-2006 Amar P. Singh wrote:
> Hi All,
>
> This is my first email to the group and I hope that I landed in the
> correct place.
>
>
>
> Ok now coming to the problem. Can someone explain to me that what this
> script is doing. I want to know the meaning of all the lines in the
> script.
>
>
>
> $val = defined $val ? $val : "null";
>
> $val =~ s/\'/$& x 2/eg; # double pad single
> quote character '
>
>
>
> Please help me out understand the meaning of the lines above.
>
>
>
> With Regards,
>
>
>
> Amar P Singh
>
> desk: +91 124 4167037
>
> mobile: +91 (0) 9810788298
> e-mail: asingh4@sapient.com
>
>
>

Re: Perl script

am 25.07.2006 15:01:24 von stuart.cooper

> Ok now coming to the problem. Can someone explain to me that what this
> script is doing. I want to know the meaning of all the lines in the
> script.

> $val = defined $val ? $val : "null";

> $val =~ s/\'/$& x 2/eg; # double pad single
> quote character '

the first line sets val to null if it wasn't defined.
the second line double pads the single quote character.

Re: Perl script

am 25.07.2006 16:06:26 von david

Martin J. Evans wrote:
> This is not the correct list for this question - this list is for Perl DBI
> users. Try http://lists.cpan.org/showlist.cgi?name=beginners.

Quite possibly, but the exact question rings alarm bells.

> Martin
> --
> Martin J. Evans
> Easysoft Ltd, UK
> http://www.easysoft.com
>
>
> On 25-Jul-2006 Amar P. Singh wrote:
>> Hi All,
>>
>> This is my first email to the group and I hope that I landed in the
>> correct place.
>>
>>
>>
>> Ok now coming to the problem. Can someone explain to me that what this
>> script is doing. I want to know the meaning of all the lines in the
>> script.
>>
>>
>>
>> $val = defined $val ? $val : "null";
>>
>> $val =~ s/\'/$& x 2/eg; # double pad single
>> quote character '

This smells bad. This sounds like some poorly written code that is
trying to insert values into a database, and the programmer noticed that
the simple-minded approach of (e.g.)

"insert (first, last) vakues ('$first', '$last') into t"

fails when $last eq "O'Donovan" because of quoting problems. And so they
tried to dick around with doubling up quotes.

So, my suggestion to the OP is "learn about placeholders".

David
--
Much of the propaganda that passes for news in our own society is given
to immobilising and pacifying people and diverting them from the idea
that they can confront power. -- John Pilger

RE: Perl script

am 25.07.2006 17:08:21 von Ron.Reidy

This is not a DBI issue. If you want to know about these types of
constructs, please refer to the following docs:

1. The Perl man pages - In your case,
http://search.cpan.org/dist/perl/pod/perlop.pod and
http://search.cpan.org/dist/perl/pod/perlre.pod

2. The camel book - http://www.oreilly.com/catalog/learnperl4/ and The
Perl Cookbook - http://www.oreilly.com/catalog/perlckbk2/



-----Original Message-----
From: Amar P. Singh [mailto:asingh4@sapient.com]=20
Sent: Monday, July 24, 2006 11:03 PM
To: dbi-users@perl.org
Subject: Perl script

Hi All,

This is my first email to the group and I hope that I landed in the
correct place.

=20

Ok now coming to the problem. Can someone explain to me that what this
script is doing. I want to know the meaning of all the lines in the
script.

=20

$val =3D defined $val ? $val : "null";

$val =3D~ s/\'/$& x 2/eg; # double pad single
quote character '

=20

Please help me out understand the meaning of the lines above.

=20

With Regards,

=20

Amar P Singh

desk: +91 124 4167037

mobile: +91 (0) 9810788298=20
e-mail: asingh4@sapient.com

=20


This electronic message transmission is a PRIVATE communication which =
contains
information which may be confidential or privileged. The information is =
intended=20
to be for the use of the individual or entity named above. If you are =
not the=20
intended recipient, please be aware that any disclosure, copying, =
distribution=20
or use of the contents of this information is prohibited. Please notify =
the
sender of the delivery error by replying to this message, or notify us =
by
telephone (877-633-2436, ext. 0), and then delete it from your system.